安卓:是否有可能添加ZIP文件作为原料资源,并的ZipFile看了吗? [英] Android: is it possible to add ZIP file as a raw resource and read it with ZipFile?

查看:235
本文介绍了安卓:是否有可能添加ZIP文件作为原料资源,并的ZipFile看了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能ZIP文件添加到APK包作为原料资源,而对的ZipFile类看过吗?它看起来是微不足道的打开从SD卡的文件,而不是从APK。

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.

推荐答案

我不这么认为。至于你提到,它很容易使用的ZipFile 与文件系统上的实际文件,但不能因此对嵌入式应用程序中的一个文件。

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.

有关在访问您的APK一个zip文件,你必须使用像<一个href=\"http://developer.android.com/reference/android/content/res/Resources.html#openRawResource%28int%29\"相对=nofollow> Resources.openRawResource(R.raw.zip_file) 然后包裹退回的InputStream ZipInputStream 并做到这一点通常的Java方法,而不是Android的方法。

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.

另外,如果你真的觉得你需要使用的ZipFile 类,你可以从APK zip文件解压到SD卡,或者更可靠,你应用程序的本地存储。

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.

这篇关于安卓:是否有可能添加ZIP文件作为原料资源,并的ZipFile看了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆