Inserting values to SQLite table in Android

前端 未结 8 2084
抹茶落季
抹茶落季 2020-12-09 16:42

I am new in android app developement. I tried to insert values to SQLite database through the below code;

public class cashbook extends Activity {

    @Over         


        
8条回答
  •  Happy的楠姐
    2020-12-09 16:58

    Seems odd to be inserting a value into an automatically incrementing field.

    Also, have you tried the insert() method instead of execSQL?

    ContentValues insertValues = new ContentValues();
    insertValues.put("Description", "Electricity");
    insertValues.put("Amount", 500);
    insertValues.put("Trans", 1);
    insertValues.put("EntryDate", "04/06/2011");
    db.insert("CashData", null, insertValues);
    

提交回复
热议问题