Insert in SQLite Database android

后端 未结 5 886
深忆病人
深忆病人 2020-12-31 09:26

im new on Android. I have some trouble with the insert statement in the database, when im running the application the values have not been inserted. Please someone can help.

5条回答
  •  情话喂你
    2020-12-31 10:16

    Remove the semicolons from your insert statements and add quotes around 0:

    String ROW1 = "INSERT INTO " + TABLE_ACCOUNT + " ("
                  + KEY_BANKNAME + ", " + KEY_TYPE + ", "
                  + KEY_ACCNUM + ", " + KEY_BALANCE + ", "
                  + KEY_EXPIRYDATE + ") Values ('Cash', '', '', '0', '')";
    db.execSQL(ROW1);
    

    Better yet, heed the suggestion at execSQL() and use insert() instead.

提交回复
热议问题