I'm following the guide at http://developer.android.com/training/basics/data-storage/databases.html
with minor changes to fit my needs, but my application crashes as soon as it tries to create the table. Logcat displays a sqlite exception, syntax error near index. Even though I've tripled checked and the syntax looks correct.
The exception reads: near "index": syntax error (code 1): , while compiling: CREATE TABLE my_locations ( index INTEGER PRIMARY KEY, loc_name TEXT, loc_id TEXT);
Here is my code
private static final String TEXT_TYPE = " TEXT";
private static final String COMMA_SEP = ", ";
private static final String SQL_CREATE_ENTRIES =
"CREATE TABLE " + FeedEntry.TABLE_NAME + " ( " +
FeedEntry.COLUMN_NAME_INDEX + " INTEGER PRIMARY KEY, " +
FeedEntry.COLUMN_NAME_LOC_NAME + TEXT_TYPE + COMMA_SEP +
FeedEntry.COLUMN_NAME_LOC_ID + TEXT_TYPE +
");";
private static final String SQL_DELETE_ENTRIES =
"DROP TABLE IF EXISTS " + FeedEntry.TABLE_NAME;
// If you change the database schema, you must increment the database version.
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "PersonalLocations.db";
public PersonalLocationsDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL(SQL_CREATE_ENTRIES);
}