I'm developing an Android app which needs to download a lot of data.
I'd like to measure the data traffic of my app for specific period of time (like month).
This option is available on System Settings -> Data Usage.
- Is there any way to access this setting programmatically?
- Can I use some of android libs to get traffic?
I know about TrafficStats class but I can not get traffic for specific period of time and when i boot device this data is lost.
try these code below:
Also, in
AndroidManifest.xml
, you need to addYou can set an alarm or thread in service to get traffic periodically with TrafficStats for all process. If you want to get traffic of each process, I think you can see this answer.