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 trialAdlight Sibanda
5,701 Pointsnot 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".
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
James Simshaw
28,738 PointsHello,
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.
Adlight Sibanda
5,701 Pointspublic 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); } }
Jose Garcia
2,166 PointsLate, 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)";
Adlight Sibanda
5,701 PointsAdlight Sibanda
5,701 PointsJames
I have made the change above but not getting through im still missing the picture..
James Simshaw
28,738 PointsJames Simshaw
28,738 PointsAre you still having issues? The code you posted in your other comment seems to pass when I copy and paste it in.