12

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?

Md. Sabbir Ahmed
  • 850
  • 8
  • 22
Daniele C
  • 171
  • 1
  • 5
  • @ModularSynth no, it's not. sorry didn't explained well. I need to do it via code in an app of course – Daniele C Sep 03 '17 at 16:23
  • 2
    Guys this question isn't off topic at all. He explained it so why all this downvotes? – Daniele Sep 03 '17 at 16:28
  • https://developer.android.com/reference/android/net/TrafficStats.html – Mukesh M Sep 03 '17 at 16:30
  • 2
    Asking for a tutorial is actually very [off-topic](https://stackoverflow.com/help/on-topic), here. – Phantômaxx Sep 03 '17 at 16:40
  • 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. – Mukesh M Sep 03 '17 at 16:53

1 Answers1

12

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.

Mukesh M
  • 2,242
  • 6
  • 28
  • 41