本文介绍了如何获取已安装应用程序的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试计算已安装应用程序的大小.
I am trying to calculate the size of the installed application.
我在这里找到了答案
我在一些设备上测试过,除了三星 Galaxy Note3(4.3) 没有问题.
I have tested it on some devices, and there is no problem except Samsung Galaxy Note3(4.3).
我收到此错误:java.lang.NoSuchMethodException: getPackageSizeInfo()
I get this error: java.lang.NoSuchMethodException: getPackageSizeInfo()
我想知道有没有其他方法可以获取已安装应用的大小?
I'm wondering is there any other way to get the size of an installed app?
推荐答案
试试这个...
public static long getApkSize(Context context, String packageName)
throws NameNotFoundException {
return new File(context.getPackageManager().getApplicationInfo(
packageName, 0).publicSourceDir).length();
}
这篇关于如何获取已安装应用程序的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!