DatabaseHandler db;
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String Standard = "https://play.google.com/store/apps/details?id=";
String id= url.substring(Standard .length(), url.indexOf("&"));
db.addContact(new Contact(id));
public class FunActivity extends Activity implements OnItemClickListener {
DatabaseHandler db;
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);
for(int i=0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
if ( ((p.packageName).equals("db.list???")) //what i write here
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);
答案 0 :(得分:0)
从数据库中获取列表
在数据库处理程序中添加此方法
public ArrayList<String> getAllApps() {
String selectQuery = "SELECT * FROM table";
ArrayList<String> apps = new ArrayList<String>();
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
apps.add(cursor.getString("your column name"));
} while (cursor.moveToNext());
}
// return list
return apps;
}
首先从数据库中获取列表并添加到Arraylist
然后将您的应用名称与它们进行比较
arraylist = dbHelper.getAllApps();
在if ( ((p.packageName).equals("db.list???"))
中
替换为
if (arraylist.contains(p.packageName))
{
add();
}
else
{
donothing();
}