Insert null in Sqlite table

后端 未结 4 628
逝去的感伤
逝去的感伤 2020-12-29 20:51

I am trying to figure how to insert a null value into an SQLite table in Android.

This is the table:

\"create table my table (_id integer primary key         


        
4条回答
  •  太阳男子
    2020-12-29 21:00

    Yes, you can skip the field in ContentValues and db.insert will set it NULL. Also you can use the other way:

    ContentValues cv = new ContentValues();
    cv.putNull("column1");
    db.insert("table1", null, cv);
    

    this directrly sets "column1" NULL. Also you can use this way in update statement.

提交回复
热议问题