insert initial data to sql lite android

前端 未结 4 1442
生来不讨喜
生来不讨喜 2021-01-26 00:34

I\'m developing an expense tracker where I want to populate the DB with a few records when the application first start. I tried to call the method in my splash activity and add

4条回答
  •  猫巷女王i
    2021-01-26 01:17

    Make a habit of formatting your code well. The last column definition does not have a comma :

        String CREATE_USER_TABLE = "CREATE TABLE " + TABLE_USER 
                + "(" 
                + KEY_ID      + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
                + KEY_NAME    + " TEXT, "
                + KEY_EMAIL   + " TEXT, " 
                + KEY_PW      + " TEXT, "
                + KEY_SESSION + " INTEGER "
                + ")";
    
        String CREATE_EXPENSE_TYPE_TABLE = "CREATE TABLE " + TABLE_EXPENSE_TYPE
                + "(" 
                + KEY_EXPENSE_ID   + " INTEGER AUTOINCREMENT, "
                + KEY_EXPENSE_TYPE + " TEXT PRIMARY KEY "
                + ")";
    

提交回复
热议问题