Conflict resolution in Android's SQLiteDatabase
You can specify a UNIQUE index in the table definition which will allow rows to be REPLACED:
CREATE TABLE mytable ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, UNIQUE (id) ON CONFLICT REPLACE)
If a row an INSERT or UPDATE statement tries to add a row with an id which already exists, the existing row is replaced with the new one.
There's a ON CONFLICT
clause in SQLite that you can say INSERT INTO ... ON CONFLICT...
.
Read the documentation please. http://www.sqlite.org/lang_conflict.html