Obb (Opaque Binary Blobb) getMountedObbPath() returning null

安稳与你 提交于 2019-12-23 22:28:11

问题


Why is the obb-file not found when its actually there?

in the logcat window

 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

the 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);

according to the documentation getMountedObbPath returns the following:

Check the mounted path of an Opaque Binary Blob (OBB) file. This will give you the path to where you can obtain access to the internals of the OBB.Parameters:rawPath path to OBB imageReturns:absolute path to mounted OBB image data or null if not mounted or exception encountered trying to read status

Yes - in my case you can see that main returns null

So what could be wrong

  • the .obb file is there (see image)
  • the packagename is correct (min. sdk is set to 11)

So - why is the getMountedObbPath() returning null when the file is actually there? How can I make this work?

tried with this answer but it did not work.

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);

it returns false.

expPath outputs the string:

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

Edit:

I've even created another subfolder to the obb-file (according to Developer.Android). So now the path to the obb-file is:

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

But its not working

来源:https://stackoverflow.com/questions/33553722/obb-opaque-binary-blobb-getmountedobbpath-returning-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!