0
是否可以使用replaceOrThrow()
将新行插入到Android SQLite数据库中?Android:可以replaceOrThrow()用于在SQLite数据库中插入新行
是否可以使用replaceOrThrow()
将新行插入到Android SQLite数据库中?Android:可以replaceOrThrow()用于在SQLite数据库中插入新行
没有,但有一个insertOrThrow
方法 - see the docs
它使用以下PARAMS:
public long insertOrThrow (String table, String nullColumnHack, ContentValues values)
下面的代码工作对我很好,skd26。替换应该像大多数数据库中的插入一样起作用
if (comicBook == null) {
return false;
}
long id = -1;
try {
id = mDatabase.replaceOrThrow(TABLE_NAME, null, generateContentValuesFromObject(comicBook));
} catch (SQLException e) {
Log.e("ComicBookFav", e.getMessage());
}
return id != -1;