How to get the size of installed application?

前端 未结 3 570
名媛妹妹
名媛妹妹 2021-01-15 18:01

I am trying to calculate the size of the installed application.

I found an answer here

I have tested it on some devices, and there is no problem except Sams

3条回答
  •  囚心锁ツ
    2021-01-15 18:31

    try this...

    public static long getApkSize(Context context, String packageName)
            throws NameNotFoundException {
        return new File(context.getPackageManager().getApplicationInfo(
                packageName, 0).publicSourceDir).length();
    }
    

提交回复
热议问题