0

It is possible to unzip compressed files in Android apps with these libraries:

import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;

My app performs the unzipping and creates the uncompressed file structure on disk.

Let's say now I want that my app unzips without writing to disk, so that zipped resources are extracted on demand, in real time.

I would like to know whether the unzipping algorithm is performed once for the zip archive (so it is in memory and reading is not performance critical) or on a per-file basis every time it is said to (so it is slower)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
P5music
  • 3,197
  • 2
  • 32
  • 81
  • You generally don't want to load a lot of data into your app's memory. – M. Prokhorov Apr 16 '18 at 18:02
  • @M. Prokhorov I am dealing with files that are not so memory consuming, especially with nowadays memory specs – P5music Apr 16 '18 at 18:04
  • That's the thing: zip was created long before we could allow ourselves to bloat app's memory with holding chunks of data. And file I/O in general built to deal with volumes much larger than available memory. So, no, the archive will not be held in memory. After you created a `Zip<..>Stream`, it will only create an index record, which allows you to do a random access r/w operations with selected entries, but the operation itself is done strictly on demand. – M. Prokhorov Apr 16 '18 at 18:11
  • @M. Prokhorov So if I zip a huge html page with all contents and feed the webview with extracted data, it is going to be very slow? – P5music Apr 16 '18 at 18:28

0 Answers0