Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data compression on Android (other than java.util.zip ?)

I have a lot of data (text format) to send from a device. It obviously means that I should compress it. But my question is whether there are any ways of doing it other than by zip algorithm (like this). The reason I am asking this question is over here - for a text file i.e. 7-zip is twice (!) better than zip. Which is a significant gain. And maybe there are even better algorithms.

So are there any effective ways of data compression (better than zip) available for Android?

like image 294
alex Avatar asked Jul 25 '12 08:07

alex


Video Answer


1 Answers

You would need to compile another library into your code, since I doubt that compression algorithms other than zlib are available as part of the standard libraries on the Android.

The 7-zip algorithm you refer to is actually called LZMA, which you can get in library form in the LZMA SDK. The source code is available in Java as well as C. If you can link C code into your application, that would be preferable for speed.

Since there's no such thing as a free lunch, the speed is important. LZMA will require much more memory and much more execution time to achieve the improved compression. You should experiment with LZMA and zlib on your data to see where you would like the tradeoff to fall between execution time and compression, both to choose a package and to pick compression levels within a package.

If you find that you'd like to go the other way, to less compression and even higher speed than zlib, you can look at lz4.

like image 165
Mark Adler Avatar answered Oct 10 '22 15:10

Mark Adler