Saturday, 11 August 2018

Check multiple duplicate record in SQLite

 Check multiple duplicate record in SQLite, you can define the column as UNIQUE ON CONFLICT REPLACE like
private static final String TABLE_CREATE_DIAGONESE =
        "CREATE TABLE " + TABLE_DIAGONESE + " (" +
                DIAGNONES_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                DIAGONESE_TEXT + " TEXT UNIQUE ON CONFLICT REPLACE, " +
                DIAGONESE_CREATED + " TEXT default CURRENT_TIMESTAMP," +
                DIAGONESE_ERROR + " INTEGER , "  +
                DIAGONESE_STAR + " INTEGER  "+
                ")";

You can perform insert as usual, the db would ensure no duplicates exist.