I am trying to do a simple application manager app and I couldn't manage to get the specific package size and that's the only thing left for me to do.
I tried calculating using BlockSize(StatFs) but that didn't work. I want to get the size in MB.
I am trying to do a simple application manager app and I couldn't manage to get the specific package size and that's the only thing left for me to do.
I tried calculating using BlockSize(StatFs) but that didn't work. I want to get the size in MB.
this may help you... this will give the size in bytes...
public static long getPackageSize(Context context,String packageName) {
PackageManager packageManager = context.getPackageManager();
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName,PackageManager.GET_SHARED_LIBRARY_FILES);
File file = new File(applicationInfo.publicSourceDir);
return file.length();
} catch (NameNotFoundException e) {
}
return 0;
}