views:

604

answers:

1

Is it possible to add ZIP file to APK package as a raw resource and read it with ZipFile class? It looks like it's trivial to open file from SD card, but not from APK.

+1  A: 

I don't believe so. As you alluded, it's easy to use ZipFile with an actual file on the file system, but not so for a file embedded in your application.

For accessing a zip file in your APK, you'd have to use something like Resources.openRawResource(R.raw.zip_file) and then wrap the returned InputStream in a ZipInputStream and do it the usual Java way, rather than with the Android method.

Alternatively, if you really find you need to use the ZipFile class, you could extract the zip file from the APK to the SD card or, more reliably, to your application's local storage.

Christopher