I want to compress data in android devices and send it to an ASP.net server-side, but I don't want to consume much power and sacrifice device resources. I've tried compressing data using Deflate stream on android-side and decompressing using the same stream on the server side, but the decompressed string was not the same as the original one. I tried then using GZIP stream and the recovered data was the same as the original one. As I read, Deflate stream is faster than GZIP. So what should I do? Is it the best practice to use GZip stream for data compression and decompression between Android and C#? Is there a way to recover data that is compressed using Deflate stream?
Asked
Active
Viewed 530 times
0
-
Is Android app made with C#? – Wanton Dec 08 '18 at 19:07
-
@Wanton No, Android app is programmed using Android Studio - Java. The server is implemented using ASP.net and the used classes are C#. – A.J Dec 08 '18 at 19:09
-
Are you serializing to JSON, then getting UTF-8 bytes of it, then compressing it and sending it to ASP.NET api or what? – Wanton Dec 08 '18 at 19:24
-
Yes, that is exactly what I am doing. – A.J Dec 08 '18 at 19:26
-
GZipStream in ASP.NET? You don't happen to use some old .NET framework. If I remember there where bugs fixed in 4.5 for it. – Wanton Dec 08 '18 at 19:34
-
I do use .NET Framework 4.6.1 – A.J Dec 08 '18 at 19:36
1 Answers
1
Try using DotNetZip (NuGet) instead of System.IO.Compression.GZipStream.

Wanton
- 800
- 6
- 9
-
Is DeflateStream of DotNetZipt the same as DeflateStream of Java? What is about ZlibStream? Is it the same as DeflateStream of Java? So is it better to use DefalteStream rather than using GZIPStream? – A.J Dec 09 '18 at 04:58
-
Edited my answer. You can use what ever you want from it. What I've read, that it's more compatible with Android's Java compressions than `System.IO.Compression` ones. More info about the library here https://github.com/haf/DotNetZip.Semverd – Wanton Dec 09 '18 at 08:01
-
Also I had trouble answering your question because your question didn't include code you used to compress and code you use to decompress. So it's very hard to help you with what's compatible and what's not. In future when you ask a question, you should provide all information needed to answer your question. `ZlibStream.UncompressBuffer()` might be what you want. – Wanton Dec 09 '18 at 08:15