Android如何判断应用程序是安装在手机内存中还是SD卡

2024-12-03 17:30:16
推荐回答(1个)
回答1:

/**
* 判断包名所对应的应用是否安装在SD卡上
* @param packageName
* @return, true if install on SD card
*/
public static boolean isInstallOnSDCard(String packageName) {
PackageManager pm = LauncherApplication.getApp().getPackageManager();
ApplicationInfo appInfo;
try {
appInfo = pm.getApplicationInfo(packageName, 0);

if ((appInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
return true;
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}