嗨,我正在尝试通过下面的查询删除表中的所有行
db.beginTransaction(); // db is a SQLiteDatabase object
int deleted = db.delete("user", null, null);
db.endTransaction();
我正在表中删除n行.但是表中仍然存在行.我的删除通话有问题吗?
解决方法:
在调用endTransaction之前,您需要调用setTransactionSuccessful来提交对数据库所做的所有更改:
db.beginTransaction();
int deleted = db.delete("user", null, null);
db.setTransactionSuccessful();
db.endTransaction();
来源(Android开发人员参考):
The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!