Search code examples
androiddatabasesqlitesqlexception

Android database table not created


In Android, I'm having difficulties finding out what is the problem with the following query. The coding seems correct. I'm trying the following snippet:

 DATABASE_TABLES.add("CREATE TABLE PageRights("
                +"RightsId INTEGER NOT NULL,"
                +"PageName varchar(-1) NULL,"
                +"PageId INTEGER NOT NULL,"
                +"UserId INTEGER NOT NULL,"
                +"RoleId INTEGER NOT NULL,"
                +"Add BOOLEAN NOT NULL,"
                +"Edit BOOLEAN NULL,"
                +"Delete BOOLEAN NULL,"
                +"CreatedBy varchar(-1) NULL,"
                +"CreatedDate DATE NOT NULL,"
                +"Views BOOLEAN NULL)");

The error being thrown is ;

android.database.sqlite.SQLiteException: near "Add": syntax error (code 1): , while compiling: CREATE TABLE PageRights(RightsId INTEGER NOT NULL,PageName varchar(-1) NULL,PageId INTEGER NOT NULL,UserId INTEGER NOT NULL,RoleId INTEGER NOT NULL,Add BOOLEAN NOT NULL,Edit BOOLEAN NULL,Delete BOOLEAN NULL,CreatedBy varchar(-1) NULL,CreatedDate DATE NOT NULL,Views BOOLEAN NULL)

Please help me by giving your idea .


Solution

  • android.database.sqlite.SQLiteException: near "Add"

    Add is a reserved word in MySQL. So are Edit and Delete by the way.

    Change the names of those columns to something else.