What does nullColumnHack means? [duplicate]
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);
Did you try looking at the docs?
nullColumnHack optional; may be null. SQL doesn't allow inserting a completely empty row without naming at least one column name. If your provided values is empty, no column names are known and an empty row can't be inserted. If not set to null, the nullColumnHack parameter provides the name of nullable column name to explicitly insert a NULL into in the case where your values is empty.