安装包可以移动到SD卡 [英] Is installed package can be move to SDCard

查看:139
本文介绍了安装包可以移动到SD卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我装包的列表,我怎么能找出哪一个可以移动到SD卡?

I got a list of installed packages, how can I find out which one can be move to sdcard?

List<PackageInfo> list = pm.getInstalledPackages(0);
for (int i = 0; i < list.size(); i++) {

}


    if (_pm != null) {
        List<PackageInfo> list = _pm.getInstalledPackages(0);
        for (int i = 0; i < list.size(); i++) {
            PackageInfo current  = list.get(i);
            long pkgSize = new File(current.applicationInfo.sourceDir).length();
            String pkgName = current.packageName;
            String appName = current.applicationInfo.loadLabel(_pm).toString();
            Drawable appIcon = current.applicationInfo.loadIcon(_pm);

            //if (pInfo.installLocation != PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY)//?

            PackageItem pi = new PackageItem(pkgName, pkgSize, appIcon, appName);

            if (_locationMode == LOCATION_PHONE) {
                if (!onSdCard(pkgName)) {
                    _adapter.add(pi);
                }
            } else {
                if (onSdCard(pkgName)) {
                    _adapter.add(pi);
                }
            }
        }
    }

我既不能从我目前发现.installLocation,也没有从PackageInfo .INSTALL_LOCATION_INTERNAL_ONLY找到。有什么问题吗?

I can neither find .installLocation from my current, nor find .INSTALL_LOCATION_INTERNAL_ONLY from PackageInfo. What 's the problem?

我既不能从我目前发现.installLocation,也没有从PackageInfo .INSTALL_LOCATION_INTERNAL_ONLY找到。有什么问题吗?

I can neither find .installLocation from my current, nor find .INSTALL_LOCATION_INTERNAL_ONLY from PackageInfo. What 's the problem?

推荐答案

的<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.2_r1.1/android/content/pm/PackageInfo.java#PackageInfo.0installLocation\"相对=nofollow>来源$ C ​​$ C 知道所有,

List<PackageInfo> list = pm.getInstalledPackages(PackageManager.GET_ACTIVITIES);

for (PackageInfo pInfo : list) {        
    if (pInfo.installLocation != PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY) {
        // then it can be moved to the SD card
    } else {
        // otherwise, it can only be installed on internal storage
    }
}

这篇关于安装包可以移动到SD卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆