我已经安装了一个obb文件,我得到了一条像/mnt/obb/880f5ef6a6885d1b8937f9625be73850
这样的路径,
但如何获取我的资产的最终路径(.obb文件中的myAssets文件夹)?
当我浏览到这个目录时,我发现它为空!
我已经使用此方法挂载我的.obb文件
public void mountExpansion() {
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
String packageName = "com.example.android";
String filePath = Environment.getExternalStorageDirectory()
+ "/Android/obb/" + packageName + "/" + "main."
+ xAPKS[0].mFileVersion + "." + packageName + ".obb";
final File mainFile = new File(filePath);
if (mainFile.exists()) {
Log.d(TAG, "FILE: " + filePath + " Exists");
} else {
Log.d(TAG, "FILE: " + filePath + " DOESNT EXIST");
}
if (!storageManager.isObbMounted(mainFile.getAbsolutePath())) {
if (mainFile.exists()) {
if(storageManager.mountObb(mainFile.getAbsolutePath(), null,
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(TAG,expansionFilePath+"-->MOUNTED");
}
else {
Log.d(TAG, "Path: " + path + "; state: " + state);
}
}
}))
{
Log.d(TAG,"SUCCESSFULLY QUEUED");
}
else
{
Log.d(TAG,"FAILED");
}
} else {
Log.d(TAG, "Patch file not found");
}
}else {
}
}
我在日志上有这条消息
FILE: /storage/sdcard0/Android/obb/com.example.android/main.1014001.com.example.android.obb Exists
SUCCESSFULLY QUEUED
/mnt/obb/880f5ef6a6885d1b8937f9625be73850-->MOUNTED
感谢。
答案 0 :(得分:-1)
obbPath = Environment.getExternalStorageDirectory().getPath() + File.separator + "Android/obb/" + getPackageName() + File.separator + "main.3." + getPackageName() + ".obb";
storageManager = (StorageManager)getApplicationContext().getSystemService(Context.STORAGE_SERVICE);
m_filePathString = storageManager.getMountedObbPath(obbPath) + File.separator + filename;