Android: read a GZIP file in the ASSETS folder

android, android-assets, gzip, gzipinputstream

Solution

I met the same problem when reading a gz file from assets folder.

It's caused by the file name of the gz file. Just renaming yourfile.gz to other name like yourfile.bin. It seems Android build system would decompress a file automatically if it thought it's a gz.

Problem

How can you read GZIP file in Android located in the "ASSETS" (or resources/raw) folder? I have tried the following code, but my stream size is always 1. ``` GZIPInputStream fIn = new GZIPInputStream(mContext.getResources().openRawResource(R.raw.myfilegz)); int size = fIn.available(); ``` for some reason the size is always 1. But if Idon't GZIP the file, it works fine. NOTE: Using Android 1.5

Original source