so for I know we cannot directly get internet data usage from android as we fetch call history record form call log we can get data form TrafficStats class which is since boot
To get internet data on application basic here is the simple code using packageManager to get package name of the corresponding app and using ApplicationInfo we can find the detail of the application information
final PackageManager pm = context.getPackageManager();
// get a list of installed apps.
List<ApplicationInfo> packages = pm.getInstalledApplications(0);
for (ApplicationInfo packageInfo : packages) {
// get the UID for the selected app
UID = packageInfo.uid;
String package_name = packageInfo.packageName;
Log.d("mypackagename",package_name+"");
ApplicationInfo app = null;
try {
app = pm.getApplicationInfo(package_name, 0);
} catch (PackageManager.NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String name = (String) pm.getApplicationLabel(app);
Drawable icon = pm.getApplicationIcon(app);
// internet usage for particular app(sent and received)
double received = (double) TrafficStats.getUidRxBytes(UID)
/ (1024 * 1024);
double send = (double) TrafficStats.getUidTxBytes(UID)
/ (1024 * 1024);
double totalab = received + send;}