android - 即使删除了应用程序,Cordova 应用程序中的 Web 存储也会保留
问题描述
在 Cordova Android 应用程序中,当我使用 Web 存储 (window.localStorage) 时,我注意到有时当我卸载应用程序(甚至通过adb uninstall
)并再次重建应用程序时,window.localStorage 的东西似乎会被转移。
这不仅仅是在一台 Android 设备上,我在不同的设备上多次注意到它。
这甚至可能还是只是页面被缓存了?
编辑:
我创建了一个示例项目。并使用 Cordova 8 和 Android 平台 7.0.0。配置对了吗?
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloWorld</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:allowBackup="false" />
<application android:fullBackupContent="false" />
</edit-config>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="^7.0.0" />
</widget>
解决方案
Android 6+ 会自动备份数据,并在您再次安装应用程序时恢复。
您可以通过将其添加到 config.xml 来禁用它
<edit-config file="AndroidManifest.xml"
target="/manifest/application"
mode="merge">
<application android:allowBackup="false"/>
<application android:fullBackupContent="false"/>
</edit-config>
这会使应用程序构建失败,您必须添加xmlns:android="http://schemas.android.com/apk/res/android"
到 config.xml 小部件才能使其构建。
推荐阅读
- video - ffmpeg - 在我应用多遍工作流程时保持视频质量,每个工作流程都包括再次解码和编码,在视频编辑中
- c# - 用数组中的字符串填充数据集记录
- javascript - localStorage 属性不存储元素的超文本引用属性
- flutter - 一些可以帮助我在颤振中实现日历小部件
- swift - Swift:音频播放完毕后如何设置代码执行?
- ios - MultipeerConnectivity 在 iOS 14 上无法按预期工作
- c# - CrystalDecisions.CrystalReports.Engine.dll 中的 System.Runtime.InteropServices.COMException
- java - 如何在每个类 WebClient retryWhen 中避免硬编码
- c# - SQL查询将数据插入到asp.net中包含外键的表中
- java - 我想从 GUI 窗口中获取输入并存储