Insert in SQLite Database android

后端 未结 5 919
深忆病人
深忆病人 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:20

    Change this lines. give the 0 in quotes

    you declate KEY_BALANCE as text but you are entering integer value in this field. That's y you are getting error

     public long insert_table(String BANKNAME,String TYPE,
                String ACCNUM, String BALANCE,
                String EXPIRYDATE) {
    
        this.insertStmt.bindString(1, BANKNAME);
        this.insertStmt.bindString(2, TYPE);
        this.insertStmt.bindString(3, ACCNUM);
        this.insertStmt.bindString(4, BALANCE);
        this.insertStmt.bindString(5, EXPIRYDATE);
    
        return this.insertStmt.executeInsert();
    
        }
    

    Call this method where you are trying to insert values as

    DataHelper dh = new DataHelper(this);
    dh.insert_table("Bank Account","","","0","");
    

提交回复
热议问题