我从JOBB工具创建了一个加密的OBB文件,我正在尝试访问其中的文件,有一些图像" image1.jpg,image2.jpg"到目前为止,我能够成功安装它:
public void mountExpansion() {
final StorageManager storageManager = (StorageManager) this.getSystemService(Context.STORAGE_SERVICE);
String packageName = "com.nick.app";
String filePath = Environment.getExternalStorageDirectory()
+ "/Android/obb/" + packageName + "/" + "main."
+ getString(R.string.apk_expansion_version) + "." + packageName + ".obb";
final File mainFile = new File(filePath);
if (mainFile.exists()) {
Log.d("STORAGE", "FILE: " + filePath + " Exists");
} else {
Log.d("STORAGE", "FILE: " + filePath + " DOESNT EXIST");
}
String key = "123456";
if (!storageManager.isObbMounted(mainFile.getAbsolutePath())) {
if (mainFile.exists()) {
if(storageManager.mountObb(mainFile.getAbsolutePath(), key,
new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
Log.d("PATH = ",path);
Log.d("STATE = ", state+"");
expansionFilePath = storageManager.getMountedObbPath(path);
if (state == OnObbStateChangeListener.MOUNTED) {
expansionFilePath = storageManager
.getMountedObbPath(path);
Log.d("STORAGE","-->MOUNTED");
Log.d("NICK","length()"+mainFile.length());
Log.d("NICK","getAbsolutePath()"+mainFile.getAbsolutePath());
Log.d("NICK","isDirectory()"+mainFile.isDirectory());
}
else {
Log.d("##", "Path: " + path + "; state: " + state);
}
}
}))
{
Log.d("STORAGE_MNT","SUCCESSFULLY QUEUED");
}
else
{
Log.d("STORAGE_MNT","FAILED");
}
} else {
Log.d("STORAGE", "Patch file not found");
}
}
}
在我的日志中,我看到州" 1"从OnObbStateChangeListener
返回,表示已成功装入加密的OBB文件。但是在这一点上,我无法访问其中的文件并使用它们。例如,将它们加载到ImageView
等等。对于我在这里缺少的内容有任何建议吗?
答案 0 :(得分:0)
import UIKit
class DrawLines: UIView {
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
//Drawing code
// context
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 3.0)
CGContextSetStrokeColorWithColor(context, UIColor.purpleColor().cgColor)
//create a path
CGContextMoveToPoint(context,0,0)
CGContextAddLineToPoint(context,250,320)
}
}
文件对象是obb中所有文件的目录。
要访问它们,您可以在其上调用storageManager.mountObb(main.getPath(), null, new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == MOUNTED) {
Toast.makeText(MainActivity.this, "obb mounted", Toast.LENGTH_LONG).show();
File file = new File(storageManager.getMountedObbPath(path));
} else
Toast.makeText(MainActivity.this, "mount fail :" + path, Toast.LENGTH_LONG).show();
}
});
。