Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLiteException: near /TABLE_NAME/: syntax error

please help me. I'm getting this error:

Caused by: android.database.sqlite.SQLiteException: near "values": syntax error: CREATE TABLE values (_id INTEGER PRIMARY KEY AUTOINCREMENT, name text, caption text, lines integer , photo_url text, type text);

Here is how I'm trying to create db table:

private static final String TABLE_VALUES_CREATE =
    "CREATE TABLE " + DATABASE_TABLE_VALUES +
           " (_id INTEGER PRIMARY KEY AUTOINCREMENT, "
          + ValueTemplate.KEY_NAME + " text, "
          + ValueTemplate.KEY_CAPTION + " text, "
          + ValueTemplate.KEY_LINES + " integer , "
          + ValueTemplate.KEY_PHOTOURL + " text, "
          + ValueTemplate.KEY_TYPE + " text);";

   //ValueTemplate class:
   // VALUE TEMPLATES

      public static final String KEY_CAPTION = "caption";
      public static final String KEY_NAME = "name";
      public static final String KEY_TYPE = "type";
      public static final String KEY_LINES = "lines";
      public static final String KEY_PHOTOURL = "photo_url";
like image 537
user1766287 Avatar asked Nov 16 '25 14:11

user1766287


2 Answers

I think because (values) is a reserved name, rename your table..

like image 126
Nermeen Avatar answered Nov 19 '25 05:11

Nermeen


The name of your table (values) is a keyword reserved by SQLite.

See here for the list of keywords: http://www.sqlite.org/lang_keywords.html

like image 30
Romain Guidoux Avatar answered Nov 19 '25 07:11

Romain Guidoux



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!