I need to insert or update, and I found the insertWithOnConflict method in SQLiteDatabase, but I do not know how it checks if a record exists.
Theoretically, I need the Where argument to check if a specific identifier exists, and if so, it should replace all other columns.
This is what I have now, but I don’t think the second argument is a unique id
ContentValues args = new ContentValues();
args.put(AppDatabase.COLUMN_ID, entry.getId());
args.put(AppDatabase.COLUMN_NAME, entry.getAppname());
args.put(AppDatabase.COLUMN_URL, entry.getAppUrl());
database.insertWithOnConflict(AppDatabase.TABLE_FILELIST, COLUMN_ID, args, SQLiteDatabase.CONFLICT_REPLACE);
How can I control this behavior?
source
share