Skip to content

Instantly share code, notes, and snippets.

@akbarsha03
Created June 13, 2014 10:10
Show Gist options
  • Save akbarsha03/e8d29196c9e64e54c424 to your computer and use it in GitHub Desktop.
Save akbarsha03/e8d29196c9e64e54c424 to your computer and use it in GitHub Desktop.
Check DB if a record is already exist or not
public boolean Exists(String _id) {
Cursor cursor = mDb.rawQuery("select 1 from yourTable where _id=?",
new String[] { _id })
boolean exists = (cursor.getCount() > 0);
cursor.close();
return exists;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment