Android: read a GZIP file in the ASSETS folder

后端 未结 6 1384
不思量自难忘°
不思量自难忘° 2021-01-06 08:07

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.



        
6条回答
  •  自闭症患者
    2021-01-06 08:19

    It seems that the build system treats .gz files as a special case, even when it's included as a raw resource. Rename the .gz file to have a different extension, say .raw or .bin .

    Valid at least for Android Studio 2.2 . I can't find any docs to confirm this is expected behaviour or, better, how to prevent it, but changing the extension at least works around the problem.

提交回复
热议问题