Search code examples
androidprojectapk-expansion-files

Expansion File implementation


It's been two weeks since I'm trying to implement expansion file to my application. The application only need to recover some images and I'm a bit stuck when I try to perform that in local.
I can access to the path of my .zip using this kind of code :

String path = Environment.getExternalStorageDirectory() + "/expansionfile.zip"

I can also unzip it with the following code :

Decompress d = new Decompress(zipFilename, unzipLocation);
d.unzip();` 

But I can't access to my data without unzipping the file (And it take like 30s to unzip all the images). Also, I can no longer use the images as drawables in my code, like (R.Drawable.x), and it is pretty troublesome because before exporting my images, I used them like this to display them in an ImageView:

public static int[] images = {R.drawable.1, R.drawable.2 }; 

And if I put something else as a int, it doesn't work.
Is there some sample projects about Expansion Files or something else on which I could rely ? (I've tried to read the Android Developer's guide, but it confuses me much more).


Solution

  • OK, the solution is that I just need to use this : Drawable.createFromStream(expansionFile.getInputStream("image1.png"), "src")