user693375
user693375

Reputation: 48

Android - Where do i unzip my apk expansion files too?

We have broken Google's APK size limit and are planning to send our download our sound files via expansion packs. There are two directoriess in the "assets" folder that we use to keep our oggsm, Music and Sounds

The first part went smoothly, managed to push a zipped file containing these 2 directories and about 200 files onto the obb folder and can open the zip and have access to the files within.

The problem is where do i put them?

I have been trying to get the root directory for where our apk data was originally unpacked and place the sounds back in the same place they resided before.

Is this correct or should we use the getexternalfilesdir() and place my two folders there and use the new location to play sounds from?

thanks for any responses.

Upvotes: 1

Views: 3554

Answers (1)

dagalpin
dagalpin

Reputation: 1307

Please don't unzip your APK Expansion files. Store your assets the way you would store them in the APK file (uncompressed) by using zip -0 to add them. You can then stream them directly from the APK Expansion file in place. If you unzip the APK Expansion File you will need to have the files stored twice, because if you ever update your application Google Play will download the APK Expansion file again.

All of the audio and video API's in Android will take a FileDescriptor, offset, and length.

Example:

http://developer.android.com/reference/android/media/MediaPlayer.html#setDataSource(java.io.FileDescriptor, long, long)

As it turns out, the sample code that ships with the APK Expansion File package has a function in ZipResourceFile that returns an AssetFileDescriptor.

AssetFileDescriptor objects return the offset and length, as well as the original file descriptor.

Upvotes: 4

Related Questions