title: How to check duplicates name in android database?
body: <p>I want to enter name and phone number from two edit text.i use two buttons to save and show it in emulator using list view.After entering name and when i click save button <strong>how to check whether i have already entered the same name.</strong> i am new to android explanation will be really helpful.</p>
  
  <pre><code>public void onCreate(SQLiteDatabase db) {
  
      db.execSQL("CREATE TABLE "+tbname+"("+Key_id+" INTEGER PRIMARY KEY AUTOINCREMENT, "+Key_name+" TEXT,"+Key_mobile+" TEXT)");
  
  }
  
  public void n(String aa, String bb) {
      SQLiteDatabase db=this.getWritableDatabase();
      ContentValues cv=new ContentValues();
      cv.put(Key_name, aa);
      cv.put(Key_mobile, bb);
      db.insert(tbname, Key_name, cv);
  
      db.close();
  
  }
  
  public Cursor cr()
  
  {
      SQLiteDatabase db=getReadableDatabase();
      String [] colms=new String[]{Key_id+" as _id",Key_name,Key_mobile};
      Cursor cur=db.query(tbname, colms, null, null, null, null, null);
      cur.moveToFirst();
      return cur;
  
  
  
  }
  </code></pre>