Controleer of de rij al in de database bestaat of niet, en afhankelijk van deze update of vul uw gegevens in:
public Long saveUser(Some values) {
long rowId;
String sql = "SELECT * FROM Data2 WHERE COLUMN_1 = ? AND COLUMN_2 = ?";
Cursor cursor = getSqLiteDatabase().rawQuery(sql, new String[]{"column_value_1" ,"column_value_2"});
if (cursor == null || !cursor.moveToFirst()) {
//Insert new
rowId = getSqLiteDatabase().insert(Data2, null, yourCV);
} else {
//Update
String clause = "COLUMN_1 = ? AND COLUMN_2 = ?";
String args[] = {"column_value_1" ,"column_value_2"};
rowId = getSqLiteDatabase().update(User.DB_KEYS.TABLE.toString(), UserSqlStorage.saveUserCV(user), clause, args);
}
closeCursor(cursor);
return rowId;
}