Android error - close() was never explicitly called on database

前端 未结 3 1338
说谎
说谎 2020-11-27 13:47

Where should I call close() on the code?

The LogCat returns this error:

close() was never explicitly called on database android.database.sql

3条回答
  •  春和景丽
    2020-11-27 14:01

    I suspect fillList() is called multiple times during a RatedCalls "session". So each time you create a new Cursor instance and call startManagingCursor() on it. Doing so you accumulate a list of Cursors - ArrayList to be precise that is declared in ListActivity. Normally they (cursors that are being managed) will be closed automatically in ListActivity.onDestroy(). Could you confirm your RatedCalls actually passes onDestroy().

    Do you override somehow the ListActivity.onDestroy() in RatedCalls. If yes, then do you call super.onDestroy() (you should call it) ?

    I don't get the purpose of calling onStop() in RatedCallsContentObserver.onChange() after the fillList();. I believe Activity life-cycle callbacks should be called by OS only. So maybe calling a life-cycle callback manually you somehow prevent from onDestroy() to be called by OS (just a guess)?

    UPDATE:

    Dan Breslau is right - it's db object that is not closed. Sorry for misleading.

提交回复
热议问题