Android data usage history

xiao mingming
xiao mingming used Ask the Experts™
on
Hello everyone.
I have some question for getting android data usage history programmatically.
I'm now writing an App for analyzing the data usage.
When app is installed , app have to retrieve the historic data usage information.
But I couldn't find any ways.
Once the app is installed, app can manage the data usage itself.
But I want to read the android device data usage history.
Is it possible? Please help me.
Best Regards
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Exec Consultant
Distinguished Expert 2018
Commented:
Good to check out the Android SDK and the main class you'll need is http://developer.android.com/reference/android/net/TrafficStats.html

You can use getUid{Rx|Tx}Bytes(int uid) for the given process user ID (which you can get from ActivityManager.getRunningAppProcesses()). Though I am not sure if it can run for all Android build OS but overall this has been the norm mean to quickly get some sensing to implement using the TraficStats API and track the number of bytes sent/received per UID (application). Key is that specific UID is assigned to each app (package) as an arbitrary but distinct OS user ID at each apps installation time. This make each app process runs under its own unique UID so that any apps signed with same certificate can share data, user ID, as well as run in a single process. Some info for on the details tying to the stat class http://agolovatyuk.blogspot.sg/2012/04/android-traffic-statistics-inside.html

Author

Commented:
Thank you for your Answering.
It was helpful to me.
I like your answer.
Best Regards.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial