0

I have checked out the other questions and answers similar to my issue but none are answering my issue so I hope it ok to ask:

I am getting the following error:

 Caused by: android.database.sqlite.SQLiteException: near "Group": syntax error (code 1): , while compiling: CREATE TABLE my_locations_table (_id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Group TEXT NOT NULL, Lat TEXT NOT NULL, Lng TEXT NOT NULL);
                                                                           #################################################################
                                                                           Error Code : 1 (SQLITE_ERROR)
                                                                           Caused By : SQL(query) error or missing database.
                                                                            (near "Group": syntax error (code 1): , while compiling: CREATE TABLE my_locations_table (_id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Group TEXT NOT NULL, Lat TEXT NOT NULL, Lng TEXT NOT NULL);)

Here is my code:

private final static String KEY_ROWID = "_id";
private final static String KEY_NAME = "Name";
private final static String KEY_GROUP = "Group";
private final static String KEY_LAT = "Lat";
private final static String KEY_LNG = "Lng";

and the error is occurring at this point:

@Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + DATABASE_TABLE
                + " (" + KEY_ROWID + " INTEGER PRIMARY KEY, "
                + KEY_NAME + " TEXT NOT NULL, "
                + KEY_GROUP + " TEXT NOT NULL, "
                + KEY_LAT + " TEXT NOT NULL, "
                + KEY_LNG + " TEXT NOT NULL);");
    }

After looking at this for hours now I can not see the issue?

3
  • 4
    GROUP is a keyword. Either quote it everywhere you use it as a column name, or call it something else. Commented Aug 25, 2017 at 0:39
  • 1
    See sqlite.org/lang_keywords.html Commented Aug 25, 2017 at 0:41
  • Thanks for the comments, being a newbie with SQLite I was referencing from a tutorial and did not see that Group was a keyword. Resolved. Commented Aug 25, 2017 at 0:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.