我将数据库值与 packageinfo 进行比较这是截图 http://imgur.com/psGyBGo
我在列表中获取所有数据库值 List arraylist = db.getAllApps();
如何将此列表与安装 ap 包名称列表进行比较?下面是我的代码快照请帮助我如何比较???此行不过滤值
if ( (p.packageName).equals(arraylist)) 我如何过滤值以便匹配并仅显示列表中与数据库匹配的值
private List<App> loadInstalledApps(boolean includeSysApps) {
List<App> apps = new ArrayList<App>();
// the package manager contains the information about all installed apps
PackageManager packageManager = getPackageManager();
List<PackageInfo> packs = packageManager.getInstalledPackages(0);
List arraylist = db.getAllApps();
for (int i = 0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
ApplicationInfo applicationInfo = p.applicationInfo;
// if (arraylist.equals(p.packageName))
if ( (p.packageName).equals(arraylist))
{
App app = new App();
app.setTitle(p.applicationInfo.loadLabel(packageManager)
.toString());
app.setPackageName(p.packageName);
app.setVersionName(p.versionName);
app.setVersionCode(p.versionCode);
CharSequence description = p.applicationInfo
.loadDescription(packageManager);
app.setDescription(description != null ?
description.toString()
: "");
apps.add(app);
// }
}
}
return apps;
}