When i try to retrieve traffic data using TrafficStats class,
TrafficStats.getTotalRxBytes() and TrafficStats.getTotalTxBytes() functions alwa
TrafficStats.getTotalRxBytes()
TrafficStats.getTotalTxBytes()
If you are using emulator it might not work. Try on a real device.