【发布时间】:2012-10-24 13:53:09
【问题描述】:
可能重复:
Android error - close() was never explicitly called on database
我的安卓应用有问题。
我实现了一个单例,它有一个带有以下代码的方法:
public Cursor getFooCursor(Context context)
{
StorageDBOpenHelper helper = new StorageDBOpenHelper(context);
SQLiteDatabase db = helper.getReadableDatabase();
Cursor c = db.query("Foo", new String[] {"_id", "Titel"}, null, null, null, null, "Test DESC");
return c;
}
当我使用这个时,我有时会收到错误:SQLiteDatabase: close() was never explicitly called on database
如何避免这种情况?问题是,我不能简单地在return c 之前创建一个db.close(),因为那样它是空的。
【问题讨论】: