根据SQLiteDatabase API文档:
你能给我举个例子吗?
insert(String table, String nullColumnHack, ContentValues values)
方便方法用于将一行插入数据库。
你能给我举个例子吗?
insert(String table, String nullColumnHack, ContentValues values)
方便方法用于将一行插入数据库。
有时候您想插入一个空行,在这种情况下,ContentValues
没有内容值,您应该使用 nullColumnHack。
例如,您想要在表 student(id, name)
中插入一行空白行,其中 id
是自动生成的,而 name
为空。您可以像这样进行调用:
ContentValues cv = new ContentValues();
db.insert("student", "name", cv);