Android SQLite SQLiteOpenHelper IllegalStateException - DB Already Closed Error

前端 未结 3 863
小鲜肉
小鲜肉 2020-12-25 09:41

This has been driving me crazy for a few days now. I have an android application that is pretty complex. It uses multiple threads to pull data from a server and populate t

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-25 09:51

    I had also the same problem 'db already closed exception with a cursor invalid statement in fillWindow() and IllegalStatementException'. What I did was I put my cursor (w/c also comes from SimpleCursorAdapter) to an instance variable instead of a method variable then on my onStop and onPause methods I call stopManagingCursor then on my onResume and onStart methods I call startManagingCursor.

    It solved my problem for me and I didn't find any error or warning messages in my logcat after that :) Hope this helps anyone also.

提交回复
热议问题