Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

I don't understand what I should make in this exercise!

I don't understand what I should make in this exercise!

public class AlienSQLiteHelper extends SQLiteOpenHelper {

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

  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 COLUMN_HOME_PLANET = "HOME_PLANET";

  public static final String CREATE_ALIENS = "CREATE TABLE " + ALIENS_TABLE + " (" +
          COLUMN_NAME + " TEXT, " +
          COLUMN_TYPE + " TEXT, " +
          COLUMN_HOME_PLANET + " TEXT)";

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

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

  public void onCreate(SQLiteDatabase sqLiteDatabase) {

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

Mazen Halawi
Mazen Halawi
7,806 Points

Hi, not sure of your question. but thats suppose to create a new database for you. if you are to find a mistake in it, i would presume that the onUpgrade method could be wrong, as you need to first drop the table you already have and then recall onCreate method. otherwise kindly elaborate more about the topic.

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

It looks like you're on step 4 of 5 which is asking you to change the DB_ALTER statement with the new column name and type. This is pretty much the same thing you did in step 3 to the DB_CREATE statement. Let me know if you still have trouble with that step.