Reputation: 4482
I am having trouble adding on conflict replace for a Unique on two keys:
Here is the table:
private static final String CREATE_TABLE_USERS = "CREATE TABLE "
+ TABLE_USERS + "("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ KEY_USER_ID + " TEXT NOT NULL,"
+ KEY_IS_TYPE + " INTEGER,"
+ KEY_DATE_ADDED + " LONG,"
+ "UNIQUE (" + KEY_USER_ID + ", " + KEY_IS_TYPE + ")"
+ ")";
How I insert them in Android SQLite Helper
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
return db.insert(TABLE_USERS, null, values);
I tried doing UNIQUE ON CONFLICT REPLACE
but it does not work.
Upvotes: 0
Views: 1649
Reputation: 180080
As shown in the documentation, the conflict clause must come after the column list:
...
UNIQUE (UserID, IsType) ON CONFLICT REPLACE
Upvotes: 4