SQLite syntax error near “CREATE TABLE”

后端 未结 3 798
你的背包
你的背包 2021-01-23 06:40

Here\'s my code:

    String CREATE_DATABASE = \"CREATE TABLE \" + TABLE_NAME + \"(\"  + 
            KEY_ID + \" INTEGER PRIMARY KEY AUTOINCREMENT, \" + 
                


        
3条回答
  •  攒了一身酷
    2021-01-23 07:02

    In SQLite, a column declared integer primary key will auto increment, so try removing that:

    String CREATE_DATABASE = "CREATE TABLE " + TABLE_NAME + "("  + 
            KEY_ID + " INTEGER PRIMARY KEY, " + 
            "title TEXT, "+
            "author TEXT, "+
            "state TEXT);";
    

    See this answer for reference.

提交回复
热议问题