Does this statement:
INSERT INTO table (...)
VALUES (...)
WHERE NOT EXISTS (...)
exists using Sqlite3?
EDIT:
INSERT OR IGNORE
Is not working in my case
Does this statement:
INSERT INTO table (...)
VALUES (...)
WHERE NOT EXISTS (...)
exists using Sqlite3?
EDIT:
INSERT OR IGNORE
Is not working in my case
please use this method to check if value exist in database or not.its very easy and proper way..i hope its useful to you.
public boolean isRecordExist(String TableName, String columnName,
String value) {
DbHelper dbHelper = new DbHelper(this);
dbHelper.createDataBase();
SQLiteDatabase sqldb = dbHelper.openDataBase();
String Query = "Select * from " + TableName + " where " + columnName
+ "='" + value + "'";
Cursor cursor = sqldb.rawQuery(Query, null);
if (cursor != null && cursor.getCount() <= 0) {
cursor.close();
return false;
} else if (cursor != null) {
cursor.close();
}
return true;
}