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 Using SQLite for Structured Data Creating a SQLite Table

not sure what is going wrong here.

Using this following snippet of a subclassed SQLiteOpenHelper, modify the code that creates the table to also add a TEXT field called "COMPANY_NAME".

AutoSQLiteHelper.java
public class AutoSQLiteHelper extends SQLiteOpenHelper {

  public static final String CREATE_CAR_MAKERS = 

  "CREATE TABLE CAR_MAKERS (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + COMPANY_NAME + " TEXT)";

  @Override
  public void onCreate(SQLiteDatabase database) {
    database.execSQL(CREATE_CAR_MAKERS);
  }
}

3 Answers

Hello,

You're trying to refer to a constant COLUMN_COMPANY_NAME, but you have not declared and initialized the constant. Please let us know if you need further help in doing so or anything else. Also, in order to help you from your current position, please provide your updated code with your changes.

James

I have made the change above but not getting through im still missing the picture..

Are you still having issues? The code you posted in your other comment seems to pass when I copy and paste it in.

public class AutoSQLiteHelper extends SQLiteOpenHelper { public static final String COLUMN_COMPANY_NAME = "COMPANY_NAME";

public static final String CREATE_CAR_MAKERS = "CREATE TABLE CAR_MAKERS (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_COMPANY_NAME + " TEXT)";

@Override public void onCreate(SQLiteDatabase database) { database.execSQL(CREATE_CAR_MAKERS); } }

Late, but this worked for me:

public static final String COMPANY_NAME = "COMPANY_NAME"; public static final String CREATE_CAR_MAKERS = "CREATE TABLE CAR_MAKERS (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + COMPANY_NAME + " TEXT)";