SQLite "INSERT OR REPLACE INTO" not working

Do you have a primary key or unique index defined for your table? I believe the attributes that make up the primary key or a unique index are used to determine if a row already exists or not.


In Android, you should use SQLiteDatabase.replace(), which does insert or update. With the Android SQLite implementation, you normally don't use raw queries represented as strings. See http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#replace%28java.lang.String,%20java.lang.String,%20android.content.ContentValues%29


You need to have a unique index on one or a combination of those columns.

CREATE UNIQUE INDEX idx_something ON NICKS (id_nick, name_nick, date_creation);

Tags:

Sqlite