Search code examples
androidapk-expansion-files

How to create a folder under /Android/obb?


I'm trying to use expansion files and I found an issue that I'm not able to resolve.

It seems that you can access the /Android/obb folder and eventually delete the /Android/obb/my.package.name directory (tried with some file manager), but I cannot handle this situation whithin the app.

If I just let the Google Downloader library try to download the expansion file it will hang and error (for the missing folder), but it will start if I recreate the folder.

The strange thing is that I'm able to create the folder from other apps (the same file manager that I've used to see the directory) but not from mine!

I tried with

File f = new File(Environment.getExternalStorageDirectory(), "Android/obb/my.package.name");
f.mkdirs();

but it doesn't work.

I've the permissions in the manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

and I'm targeting api 23 and compiling with the 25.


Solution

  • OP dropped the Target SDK to 22 and was able to avoid Dangerous permission work flow which was causing the issue.