nebkat
nebkat

Reputation: 8565

Android Modify Zip FIle

Is there any way of modifying a zip on android without having to extract its contents? I only need to add/remove about 10 files. If I had to extract the zip it could go up to 200mb.

Upvotes: 3

Views: 2394

Answers (2)

Kevin Day
Kevin Day

Reputation: 16383

I don't think you are going to find an easy way to do this with built in libraries. If this is a core function of your application, you may want to write your own (parsing zip isn't that hard).

Here's the general approach: start reading the zip, identify the first zip entry header - when you find the header for the entry you want to exclude, just keep reading to the next entry - otherwise, write out. Keep track of the output offset of each zipentry. Then write your own zip trailer at the end of the file.

The zip format is well defined (and not particularly complex - especially b/c you won't have to muck with flate or deflate or encryption or anything like that), and what you are trying to do is straightforward: http://www.pkware.com/documents/casestudies/APPNOTE.TXT

On the other hand, if this is not a core piece of functionality for your app, find and license a library that can do it (I doubt that you'll find open source implementations that do) and move on.

Upvotes: 0

nebkat
nebkat

Reputation: 8565

Seems its not possible without 3rd party packages. Appending files to a zip file with Java

I'll still wait for answers...

Upvotes: 2

Related Questions