I am getting contact information from server when i login through account. i am storing those information in SQLite, when user login second time, I don't want to same duplicate contact inserting again into SQLite.
i tried like this but not working
boolean exist= contact_db.CheckItem(entry.getUser());
if(!exist) {
// insert
}else {
// don't insert
}
code in DB class
Cursor mCursor = database.query(ContactsDB.TABLE_CONTACTS, allColumns,
ContactsDB.CONTACT_USERID + "= ' " + name +"'" , null, null, null, null);
if (mCursor != null && mCursor.moveToFirst())
return false;
else return true;
How to avoid the duplicates while inserting the contacts into data base?