IOException while reading from InputStream

China☆狼群 提交于 2019-11-27 22:21:16

(my post to android-developers isn't showing up, so I'll try reposting it here)

IIRC, this problem comes from trying to access files that were compressed as part of building the APK.

Hence, to work around the issue, give it a file extension that won't be compressed. I forget the list of what extensions are skipped, but file types known to already be compressed (e.g., mp3, jpg) may work.

mmathieum

Changing the file extension to .mp3 to avoid the file compression does work, but the APK of the app is much bigger (in my case 2.3 MB instead of 0.99 MB).

Is there any other way to avoid this issue ?

Here is my answer: Load files bigger than 1M from assets folder

You can compress the file for yourself with GZIP and unpack it with GZIPInputStream class.

http://developer.android.com/reference/java/util/zip/GZIPInputStream.html

You are correct, in that there is a certain size limit for extracting files. You may wish to split larger files into 1MB pieces, and have a method by which you know which files are made of which pieces, stitching them back together again when your app runs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!