Jason Jason - 10 months ago 57
Android Question

Java App uses a lot of data usage while responses are only 6Kb

I searched a lot on stackoverflow and Google, but I just couldn't find a solution. My problem is the following: my app consumes a lot of wifi usage on some devices. My app gets JSON from the server, and that's all. The problem is that the app consumes a lot of data, what seems a bit odd considering that the JSON is only 6kb...

The weirdest thing is that different devices have different data usage... Friend 1 has 100mb used, while friend 2 has used 5mb. They both use it as much times as the other.

What could be the problem? I am using threads to get the JSON, if you want to know.


I tried to find out what is causing so much data to be gathered, and I found the following: I have 5 tabs, so 5 fragments, so 5 times an HTTP Request. I found out that each HTTP request takes 12kb, while it only get ~3kb of JSON back. How is this possible? And why does it vary a lot per user?

And what if I add read and write timeouts to the connection... wil it result in less MB's used? It seems not likely to me

Answer Source

You can partly fix this by adding timeouts. I tried it, and reduced it a bit

URLConnection con = url.openConnection();