AUTOINCREMENT not working

前端 未结 1 1119
遥遥无期
遥遥无期 2021-01-25 06:11

I want to create a table with 1 predefine row in it. So, I am adding the row in onCreate();

Following is my code :

private static final String CREATE_CA         


        
1条回答
  •  醉梦人生
    2021-01-25 06:15

    The table has 2 columns so you will either need to provide 2 values, or specify the column names you want to insert to. Change

    INSERT INTO CATEGORYTABLE VALUES('Category 1')
    

    to

    INSERT INTO CATEGORYTABLE VALUES(NULL, 'Category 1')
    

    or

    INSERT INTO CATEGORYTABLE(category_name) VALUES('Category 1')
    

    For what it's worth, it's also a bad practice to catch exceptions in onCreate() or onUpgrade(). If there's a problem, the callback should not return normally.

    0 讨论(0)
提交回复
热议问题