Obb(Opaque Binary Blobb)getMountedObbPath()返回null

时间:2015-11-05 20:02:27

标签: android large-files apk-expansion-files

为什么实际上没有找到obb文件?

logcat窗口中

 11-05 20:42:33.860: I/System.out(7563): mainFile = /storage/sdcard0/Android/obb/main.11.se.sourses.thai.obb

11-05 20:42:33.860: I/System.out(7563): main = null

codesnippet

    StorageManager storage = (StorageManager) getApplicationContext().getSystemService(STORAGE_SERVICE);
    File mainFile = new File(Environment.getExternalStorageDirectory() + "/Android/obb/" +
               "main." + 11 + "." + "se.sourses.thai" + ".obb");
    String main = storage.getMountedObbPath(Environment.getExternalStorageDirectory() + "/Android/obb/");
    System.out.println("mainFile = " + mainFile);
    System.out.println("main = " + main);

根据文档getMountedObbPath返回以下内容:

检查不透明二进制Blob(OBB)文件的已安装路径。这将为您提供获取OBB内部访问权限的路径。参数:OBB imageReturns的rawPath路径:已挂载OBB图像数据的绝对路径,如果未挂载则为null或尝试读取状态时遇到异常

是的 - 在我的情况下,您可以看到主要返回 null

那可能是错的

  • .obb文件在那里(见图)
  • packagename是正确的(最小sdk设置为11)

那么 - 当文件实际存在时,为什么getMountedObbPath()返回null?我怎样才能做到这一点?

enter image description here

enter image description here

尝试了这个答案,但它没有用。

APK expansion file expPath does not exists

mycode的:

    String packageName = this.getPackageName();
    String EXP_PATH = "/Android/obb/";
    File expPathDir = new File(root.toString() + EXP_PATH + packageName);   
    int mainVersion = 11;
    File expPath = new File(expPathDir,
    String.format("main.%d.%s.obb", mainVersion, packageName));
    StorageManager storage = (StorageManager) getApplicationContext().getSystemService(STORAGE_SERVICE);
    boolean b = storage.isObbMounted(expPath.getAbsolutePath());
    System.out.println("ismounted = " + b);

它返回false。

expPath输出字符串:

  expPath = /storage/sdcard0/Android/obb/se.sources.thai/main.11.se.sources.thai.obb

编辑:

我甚至为obb文件创建了另一个子文件夹(根据Developer.Android)。所以现在obb文件的路径是:

/storage/sdcard0/Android/obb/se.sources.thai/main.11.se.sources.thai.obb

但它不起作用

0 个答案:

没有答案