title: android check duplicate values before inserting data into database
body: <pre><code>    String new_recorded_lastname="a lastname";
      ////record to database......
      Cursor cursor = db.rawQuery("SELECT lastname FROM people; ",null);
  
       if (cursor != null){
    while(cursor.moveToNext()){
  
      String recorded_lastname=cursor.getString(cursor.getColumnIndex("lastname"));
      if(!(recorded_lastname.equals(new_recorded_lastname))){ 
      //add new_recorded_lastname to database
      break;
      }
      }
      }
  </code></pre>
  
  <p>I want to have a lastname only once in my database. 
  Even though I check with "if(!(recorded_lastname.equals(new_recorded_lastname)))" this line code to, it adds same records again and again. How can I control a lastname to add only once?  </p>
  
  <p>//It works for the first record very well, but starting from the second record, it adds some lastname again and again.... </p>