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

Finally, add the statement to execute the creation of your new table

Finally, add the statement to execute the creation of your new table!

I do not know were I am going wrong, I tried using the code from video but cant seen to go around please help.

AutoSQLiteHelper.java
public class AutoSQLiteHelper extends SQLiteOpenHelper {
  public static final String COLUMN_COMPANY_NAME = "COMPANY_NAME";
  public static final String COLUMN_CAR_NAME = "CAR_NAME";
  public static final String AUTO_TABLE = "AUTO";

   public static final String CREATE_AUTO_TABLE = 
          "CREATE TABLE AUTO_TABLE (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + AUTO_TABLE + " TEXT)";

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


  public static final String CREATE_CAR_MODELS = 
                    "CREATE TABLE CAR_MODELS (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_CAR_NAME + " TEXT)";

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

2 Answers

Hello,

You're pretty close to solving this challenge. You're just trying to make too many tables. The challenge doesn't ask for a CREATE_AUTO_TABLE, so if you remove the lines referencing it, you should be able to pass this challenge. Please let us know if something isn't clear or you need more assistance.

This passed for me:

public class AutoSQLiteHelper extends SQLiteOpenHelper { public static final String COLUMN_COMPANY_NAME = "COMPANY_NAME"; public static final String COLUMN_CAR_NAME = "CAR_NAME"; public static final String AUTO_TABLE = "AUTO";

public static final String CREATE_AUTO_TABLE = "CREATE TABLE AUTO_TABLE (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + AUTO_TABLE + " TEXT)";

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

public static final String CREATE_CAR_MODELS = "CREATE TABLE CAR_MODELS (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_CAR_NAME + " TEXT)";

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