Android webview concurrency caused SQLiteException: database is locked

喜欢而已 提交于 2019-12-10 15:15:56

问题


I'm not using SQLite and webview directly, the webviews are used in the ads in my application (I'm using AdMob). There are several activities which works like workflow going back and forth and some activity run in their separate process I'm getting such exception.

android.database.sqlite.SQLiteException: error code 5: database is locked
    at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
    at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
    at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1916)
    at android.webkit.WebViewDatabase.flushCacheStat(WebViewDatabase.java:874)
    at android.webkit.CacheManager.trimCacheIfNeeded(CacheManager.java:567)
    at android.webkit.WebViewWorker.handleMessage(WebViewWorker.java:193)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:150)
    at android.os.HandlerThread.run(HandlerThread.java:60)

There is no such exception if I don't use ads.

I suppose that webview is using SQLite in background and this exception raised when one WebView in Activity A locking db for writing and the WebView in Activity B (B is running in it's own process) which is opened on top of Activity A also trying to write in database and failing because database already locked

Is there a standard way to disable unmanaged WebViews from using database, by unmanaged I mean used by third party libs like AdMob sdk or configure to not throw exception or handle the exception.

来源:https://stackoverflow.com/questions/9926901/android-webview-concurrency-caused-sqliteexception-database-is-locked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!