SQLiteDatabase created and never closed

以下のようなエラーがでたので

SQLiteDatabase created and never closed

コネクションのクローズをし忘れてるのかと思って
SQLiteDatabase.close()
を追加したがエラーがなくならない。途方に暮れてたら、以下のように実装していてCursorをcloseしてないことに気づいた

int count = db.query(null, null, null, null).getCount();

cursorをcloseするように修正して解決。

Cursor cursor = db.query(null, null, null, null);
int count = cursor.getCount();
cursor.close();