im insertinguser installed app package name in database using below code and is insert sucessfully show me in log now i want to compare system install apped with this database v
to get list from database
add this method in your Database Handler
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;
}
first Get the list from the database and add to the Arraylist
then compare your app name with them
arraylist = dbHelper.getAllApps();
in your if ( ((p.packageName).equals("db.list???"))
replace with
if (arraylist.contains(p.packageName))
{
add();
}
else
{
donothing();
}