2

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";

3 Answers 3

5

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

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

2

If you insist on keeping the exact same table name then try [values], otherwise the best would be to rename it to something like tblValues

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.