Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: is it possible to add ZIP file as a raw resource and read it with ZipFile?

Tags:

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.

like image 507
tomash Avatar asked Jan 07 '10 00:01

tomash


People also ask

Can ZIP files be opened on Android?

Files by Google allows you to extract and view contents of compressed files. Note: Only . zip files are supported.

How do I view a zip file on Android?

Download and install Files by Google from the Play Store if it's not available on your device already. Open the app, then navigate to the folder containing your ZIP file (ZIP files have a . ZIP file extension). Tap the ZIP file and select Extract from the pop-up to start the process.

What app can read ZIP files?

Whether you receive a zip file as an email attachment, or want to extract and view the contents of a zip file from the web, just “Open with WinZip”. Sharing files is safe and simple too, with direct integration with multiple clouds. WinZip makes it easy to handle major compressed types of files on your Android device!

How can I open raw file in Android Studio?

Step 2: Open your android studio go to the app > res > right-click > New > Android Resource Directory as shown in the below image. Step 3: Then a pop-up screen will arise like below. Here in Resource type choose raw.


1 Answers

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.

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.

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.

like image 143
Christopher Orr Avatar answered Oct 02 '22 13:10

Christopher Orr