How to check mobile data usage programmatically?

8.3k views Asked by At

The question is pretty straight forward, How do I find out how much mobile data (in GB or MB) has the user used in the current month?

As it has been reported as off topic, I want to clarify that the data usage is supposed to be checked via code in an app.

Is there some code I can use to check for the users used data?

1

There are 1 answers

1
Mukesh M On

See: https://developer.android.com/reference/android/net/TrafficStats.html

Try:

Toast.makeText(this, android.net.TrafficStats.getMobileRxBytes()+"Bytes", Toast.LENGTH_SHORT).show();

getMobileRxBytes() Return number of bytes received across mobile networks since device boot.