【发布时间】:2014-04-11 09:24:48
【问题描述】:
04-11 05:05:17.837: W/SQLiteConnectionPool(6454): A SQLiteConnection object for database Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
这是我的 logcat 返回的错误,我在here 和here 中搜索了此错误的可能解决方案,说您应该关闭数据库,但我有此代码
@Override
protected void onPause() {
super.onPause();
if (db.isOpen()) {
db.close();
}
}
关于我所有的活动,所以我想知道为什么会出现这个错误
【问题讨论】:
-
你确定每个光标在你完成后都关闭了吗?
-
即使使用上面的代码,是否有可能打开游标?我是否需要每次打开数据库以进行原始查询、插入和更新时都输入 db.close()?
-
不需要这个,你也可以在 onDestroy 中试试
-
还有一件事 - protected void onDestroy() { super.onDestroy(); if (db.isOpen()) { db.close(); } } 也试试这个