我想从sd卡/文件夹中删除带有标签名称和图标的apk文件信息,以便在列表视图中显示。
我正在尝试
for (int i = 0; i < FilesInFolder.size(); i++)
{
PackageManager pm = this.getPackageManager();
String dir = "mnt/sdcard/" + FilesInFolder.get(i);
PackageInfo pi=pm.getPackageArchiveInfo(dir,0);
System.err.println("files were " + pi);
pi.applicationInfo.sourceDir = dir;
pi.applicationInfo.publicSourceDir = dir;
Drawable APKicon = pi.applicationInfo.loadIcon(pm);
String AppName = (String)pi.applicationInfo.loadLabel(pm);
}
FilesInFolder是ArrayList<String>
,其中所有文件名都存储在sd卡文件夹中。我能够从sd卡文件夹中正确获取所有文件,但我的PackageInfo pi
值为所有文件的空值
这是我的logcat
10-29 00:55:14.832: W/PackageParser(17057): Skipping dir: mnt/sdcard/tudou.apk
10-29 00:55:14.832: W/System.err(17057): files were null
10-29 00:55:14.833: W/PackageParser(17057): Skipping dir: mnt/sdcard/com.nexbits.video-1.apk
10-29 00:55:14.833: W/System.err(17057): files were null
10-29 00:55:14.834: W/PackageParser(17057): Skipping dir: mnt/sdcard/com.myapp.locksettings-2.apk
10-29 00:55:14.834: W/System.err(17057): files were null
任何人都可以把我弄到我坚持的地方吗?