0

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.

dimo414
  • 47,227
  • 18
  • 148
  • 244
  • Could you add more code / context? As is, what you're trying to do and what you've tried is still unclear. – dimo414 Dec 30 '13 at 06:31
  • Possible duplicate of [Getting installed app size](https://stackoverflow.com/questions/1806286/getting-installed-app-size) – Tamás Bolvári Jan 31 '19 at 11:36

1 Answers1

0

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;
}
Gopal Gopi
  • 11,101
  • 1
  • 30
  • 43