Android-应用程序更新后WebView html5本地存储不持久 [英] Android - WebView html5 local storage not persistant after app update

查看:102
本文介绍了Android-应用程序更新后WebView html5本地存储不持久的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用HTML5本地存储的应用程序.打开或关闭应用程序时,本地存储中的数据在整个应用程序中都是持久的.但是,从商店更新应用程序时,本地存储已被删除.有没有一种方法可以防止在应用程序更新期间丢失本地存储?谢谢!

I have an application that uses HTML5 local storage. The data in local storage is persistent throughout the app, while the app is open or closed. However, when the app was updated from the store, the local storage was erased. Is there a way to prevent the loss of local storage during app updates? Thanks!

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);

推荐答案

此处

博伊福克斯先生给出的答案是

The answer given by Mr Boyfox 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/");
}

这篇关于Android-应用程序更新后WebView html5本地存储不持久的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆