According to the SQLiteDatabase API documentation:
insert(String table, String nullColumnHack, ContentValues values)
Convenience method for inserting a row into the database.
What does nullColumnHack means?
Can you give me an example?
Sometimes you want to insert an empty row, in that case ContentValues
have no content value, and you should use nullColumnHack.
For example, you want to insert an empty row into a table student(id, name)
, which id
is auto generated and name
is null. You could invoke like this:
ContentValues cv = new ContentValues();
db.insert("student", "name", cv);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With