Search code examples
androidapk-expansion-files

How do apps like BattlegroundMobile access to obb without storage permissions?


I've done developing obb function on my game app. To explain the logic of obb function simply,

  • makes a zip file with assets and rename as .obb.
  • uploads it to play store with apk. then it automatically makes an obb file with build version code.
  • extracts obb file to app data folder with java.util.zip and mount to the assets.

but if do extracting assets, it should require external storage permissions. and it makes 10%~15% loss of customers.

Also lots of posts I've been looking for are saying permission should be needed. but some apps like battlegroundmobile don't request access permission although it uses obb function.

So, I want to know how the apps avoid permission requirement programmatically.


Solution

  • extracts obb file to app data folder with java.util.zip and mount to the assets.

    Maybe that's where your problem is.

    Battleground Mobile is not copying or extracting the obb file to Internal Storage. It is accessing the data stream in the file inside the OBB folder. If you just use the file in the OBB folder, you don't need to ask permission for it.

    The download size is 1.53 GB. The obb file is in under Internal Storage - Android - obb - com.tencent.ig folder. Its size is 1.53 GB. So the APK size is pretty small.

    It downloads an extra 195 MB update data after it starts up. The downloaded files are stored in

    /storage/emulated/0/Android/data/com.tencent.ig

    Internal Storage - Android - data

    which you can access via getExternalFilesDir.

    Again, there is no need to ask permission to download into or read that folder.

    The total app storage is 1.85GB. App: 1.65 GB Data: 202 MB Cache: 10.59 MB

    If you clear data, it will remove all the updates. But the content in the OBB folder remains.