title: why does db.insert() giving the sqliteconstraintexception error 19 constraint failed
body: <p>I have read most of the questions related to this exception but none of them are clear or indicative of why db.insert would throw this error. It was working fine without errors until I manually deleted the db from DDMS. Following is my SQLiteOpenHelper code:</p>
  
  <pre><code>public class LoginSQLiteOpenHelper extends SQLiteOpenHelper {
  
  public static final String DB_NAME = "logincredentials.sqlite";
  public static final int DB_VERSION_NUMBER = 1;
  public static final String DB_TABLE_NAME = "credentials";
  public static final String USERNAME = "user_name";
  public static final String PASSWORD = "password";
  
  private static final String DB_CREATE_SCRIPT =  "create table " + DB_TABLE_NAME +
                      "( _id integer primary key autoincrement," +
                      USERNAME + " text not null, " +
                      PASSWORD + " text not null );" ;
  
  public LoginSQLiteOpenHelper(Context context) {
      super(context, DB_NAME, null, DB_VERSION_NUMBER);
  
  }
  
  @Override
  public void onCreate(SQLiteDatabase aSqliteDB) {
      Logger.d("Create", "Creating the database...");
      aSqliteDB.execSQL(DB_CREATE_SCRIPT);
  }
  }
  </code></pre>
  
  <p>My code for inserting the values is:</p>
  
  <pre><code>ContentValues contentValues = new ContentValues();
  contentValues.put(LoginSQLiteOpenHelper.USERNAME, loginId);
  contentValues.put(LoginSQLiteOpenHelper.PASSWORD, password);
  database.insert(LoginSQLiteOpenHelper.DB_TABLE_NAME, null, contentValues);
  </code></pre>