In my application I want to calculate data usage when application is in foreground.
I am using Trafficstats API.
But some time this value get reset and start from 0.
Is there any other method or API to take data usage other than using Trafficstats which will never get reset.
Or is there any ways to track when that data gets reset?
My answer here is based on assumptions, and not on proven hard facts, but normally the counters in TrafficStats should not reset except for on reboot of the device. However, the data received from trafficStats are stored as long, and whenever the total value of the received/transmitted data exceeds the maximum capacity of a long, then it will appear as the stats have been reset as the long value will overflow.