====================問題描述====================
異常日志如下:
Caused by: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed. at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:962) at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:599) at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348) at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894) at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834) at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:196) at android.database.AbstractCursor.moveToNext(AbstractCursor.java:244)
我知道這是數據庫連接被關閉導致的,但是怎么解決這個問題呢,網上能找到的解決辦法都試了,還是會報這個問題,請教高人指點!
====================解決方案1====================
那就在使用后才關閉啊
====================解決方案2====================
是不是沒有關閉cursor,然后再次訪問造成的異常
====================解決方案3====================
光這么點代碼難辦啊,最好能描述下db的使用的流程
====================解決方案4====================
放線程里有問題,放服務里沒問題?
是不是線程沒執行完(數據庫沒來得及close)就強制結束了。
====================解決方案5====================
sqllite 是不支持多線程 同時 讀寫的,是不是這個問題?