Have a webpage running HTML5 javascript webapp in a webview (with WebViewExtras and WebViewSettings). The webapp writes SQL tables and local storage.
This storage gets cleared at sometime. During Activity_Create with firstTime=true, the database and local storage are gone and the whole webapp resets, not a good user experience.
Is this because the webview process has been cleaned up by Android ? If so, how to stop the cached database from being lost?
I've tried using a WebViewSettings.databasepath of File.DirInternalCache and a directory I made myself in /sdcard, some problem.
Checking the cache files, the localStorage data is retained, but is just not read by the webview on restart.
Solution (I hope)....
There is a second webview in this application, it is only used to display logs and so not linked to WebViewExtras and WebViewSettings.
However, applying the same WebViewSettings that are used on the first webview (that was accessing localStorage) onto the second webview, appears to allow the main webview to read localStorage.
Checking the cache files, the localStorage data is retained, but is just not read by the webview on restart.
Solution (I hope)....
There is a second webview in this application, it is only used to display logs and so not linked to WebViewExtras and WebViewSettings.
However, applying the same WebViewSettings that are used on the first webview (that was accessing localStorage) onto the second webview, appears to allow the main webview to read localStorage.
I am having this same problem (localStorage works as long as the app is running, but is not read on restart). I only have the one WebView. I tried adding a second one, making it invisible and calling the same WebViewSettings calls as I do for the first, but it did not fix it. Does your workaround work consistently for you? If so, can you post some sample code?