Android - WebView html5 local storage is not saved after application update

I have an application using local HTML5 storage. Data in local storage is persistent throughout the application, and the application is open or closed. However, when the application was updated from the repository, the local repository was erased. Is there a way to prevent local storage loss during application updates? Thank!

mWebView = (WebView) findViewById(R.id.mWebView);
WebSettings mWebSettings = mWebView.getSettings();
mWebSettings.setAllowFileAccess(true);        
mWebSettings.setDatabaseEnabled(true);
mWebSettings.setDatabasePath("/data/data/"+this.getPackageName()+"/databases/");
mWebSettings.setDomStorageEnabled(true);
mWebSettings.setJavaScriptEnabled(true);
+3
source share
1 answer

There are replies to this post here.

The answer given by Mr. Boyfs was

webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    webView.getSettings().setDatabasePath("/data/data/" + webView.getContext().getPackageName() + "/databases/");
}
0
source

All Articles