title: How to check if contact exists in database android
body: <p>How can i check if a specific contact is exist in the android database to add it to the database or not, the problem if i check with contact name there maybe another contact with the same name so can any one help me, my code is :</p>
  
  <pre><code>String where = ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY+" = ? AND "+
                 ContactsContract.RawContacts.ACCOUNT_TYPE + " = ? AND "+ 
                 ContactsContract.RawContacts.ACCOUNT_NAME+" = ?";
  String[] whereArg = new String[] {displayName, AccountType, AccountName};
  
  Cursor SameName = cResolver.query(ContactsContract.RawContacts.CONTENT_URI, null, where, whereArg,null);
  
  if (SameName == null || SameName.getCount() == 0) {
                      // the addContact method
                  }else {
  
                      // do nothing, the contact is exsist
  
                  }
  </code></pre>