Extract and manipulate 7Zip on Android

posted in: Android, Guides, Java | 0

Some days I get stuck on a really simple task. I never had to manipulate compressed archives (zip, 7zip..) on Android and could never imagine it was so hard. The difficulty is not to do it but much in the documentation about how to do it.

By searching I found:

All of this is just old and inapropriate on how to do it the simple way…




After some searches I found about Apache’s commons compress library that supports a lot of archive types: ar, cpio, Unix dump, tar, zip, gzip, XZ, Pack200, bzip2, 7z, arj, lzma, snappy, DEFLATE and Z files.



With the gradle build system, just add

compile 'org.apache.commons:commons-compress:1.8'




Here is a sample of code on how to use this to extract all files of a 7Zip archive:




This library is really simple to use and robust. The only downside of it is that it my be too powerfull and too big for a simple project.

I hope you won’t lose time as I did searching for a simple solution!

Leave a Reply