i am using SqliteDatabase on Android and i was always using
if (mDB.update(CITIES_TABLE, values, _ID + " = " + id + " AND " + _KEY + " = '" + key + "'", null) == 0) {
mDB.insert(CITIES_TABLE, null, values);
}
//_KEY and _ID are composite Primary Keys...
but now i noticed that there is a insertWithOnConflict and CONFLICT_REPLACE as ConflictAlgorithm, which should do the same...
But the question ist now: which one to use? which one is better? insertWithOnConflict seems more clear (in Code) to me...
i know that CONFLICT_REPLACE will change the RowId, which i am not using either...
Aucun commentaire:
Enregistrer un commentaire