Android Android Data Persistence Migrating a SQLite Database Adding a New Field

Tinashe Gwariro
Tinashe Gwariro
4,691 Points

Failing to create increament

Not sure how I should go about this

AlienSQLiteHelper.java
public class AlienSQLiteHelper extends SQLiteOpenHelper {

  public static final String DB_NAME = "aliens.db";
  public static final int DB_VERSION = 1;

  public static final String ALIENS_TABLE = "ALIENS";
  public static final String COLUMN_NAME = "NAME";
  public static final String COLUMN_TYPE = "TYPE";

  public static final String CREATE_ALIENS = "CREATE TABLE " + ALIENS_TABLE + " (" +
          "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
          COLUMN_NAME + " TEXT, " +
          COLUMN_TYPE + " TEXT)";

  public static final String DB_ALTER = "ALTER TABLE " + ALIENS_TABLE + " ADD COLUMN ";

  public AlienSQLiteHelper(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase sqLiteDatabase) {
    sqLiteDatabase.execSQL(CREATE_ALIENS);
  }

  @Override
  public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
    switch (oldVersion) {
      case 1:

    }
  }
}

1 Answer