using and/or extracting expandable files (obb) android

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


using and/or extracting expandable files (obb) android



I was able to upload an expandable file and download it
on my app from google play. Following the o[fficial tutorial][1]


[fficial tutorial][1]



It saved the obb file to /Android/Obb/main.2.myappname.obb



I assumed this obb file would be extracted on assets or raw folder or
something similiar. The obb file was renamed after I zipped about 20 .mp3
files. They are named like so: 1.mp3, 2.mp3 etc.



Is it possible to extract the obb file if not how will I be able to
access the invididual mp3 files, the way I am able to access them from
assets or raw folder. Let's say I want to access 1.mp3 which is present
on the .zip archive that was renamed to main.2.myappname.obb



Thank you.




2 Answers
2



I'm surprised that no one has chimed in here. You can use the StorageManager to mountObb(), unmountObb(), getMountedObbPath(), and isObbMounted(). After mounting an Obb and calling getMOuntedObbPath, you can use the path returned to do normal reads from it. It acts as a virtual drive. You just cannot write back to it.



Here's the link to the documentation: https://developer.android.com/reference/android/os/storage/StorageManager.html





what do i name the obb file if my app version is in the format 0.0.9 for instance? is it just 9? the integer equivalent?
– FlavorScape
Jun 27 '16 at 21:11





The build number is usually an auto incremented number from your build system. This is your best candidate. So, 1.0.343 is your version NAME and 343 is your build number.
– Darthg8r
Jul 5 '16 at 14:23







yes, i didn't realize the semantic version is uploaded, but a new build is issued by the Play Store for the actual build. The one issued by the server is the one you'd use.
– FlavorScape
Jul 13 '16 at 19:45



You can read from the OBB directly via an InputStream using the APK Expansion Zip Library. Documentation:
https://developer.android.com/google/play/expansion-files?hl=ko#ZipLib


InputStream


APK Expansion Zip Library



Sample code:


try {
String obbFilePath = mContext.getObbDir() + "/" + "main.{package_name}.{version_code}.obb";
ZipResourceFile expansionFile = new ZipResourceFile(obbFilePath);
InputStream inputStream = mExpansionFile.getInputStream("1.mp3");
} catch (Exception e) {
Log.d(TAG, "Exception loading obb: " + e);
}



In place of the last line, since you are streaming a MP3, using MediaPlayer is a better idea.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Will Oldham

Makefile test if variable is not empty