我在Android设备中卸载并安装了离子v1应用程序后,$ localStorage数据已存在 [英] $localStorage data already there after I uninstalled and installed the ionic v1 app in Android device
问题描述
我正在开发离子v1移动应用程序。当我从
Android设备上卸载应用程序时,在我再次安装应用程序后, $ localstorage
中保存的数据已经存在。
I am developing an ionic v1 mobile application. When I uninstalled the app from
Android device, the data saved in $localstorage
are already persist there after I installed the app again.
我也在使用 cordova-plugin-crosswalk-webview
版本 2.2.0
其他信息:
Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.1.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Node Version: v4.4.1
我很乐意欣赏任何一种你的帮助。
I would gladly appreciate any kind of your help.
谢谢!
推荐答案
这是奇怪的但也是一个普遍的问题。
It's an odd but also a common problem.
如果您有退出按钮,您可以这样做:
If you have a logout button you can simply do:
$scope.logout = function(){
$window.localStorage.clear();
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
};
另一种解决方案是,当应用程序在app.js中启动时,您可以添加以下代码:
Another solution is, when the app starts in app.js you can add this code:
$window.localStorage.clear();
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
然后使用新内容更新localstorage。
and then update the localstorage with the new content.
如果用户卸载应用程序(没有注销),则无法捕获离子中的卸载事件。
In case that user uninstall the app (without logout), you can't catch an uninstall event in ionic.
另一方面,Android 6具有自动功能备份on(localstorage在版本< 6的情况下持久保存数据?你试试吗?)。
From the other hand Android 6 has automatic backup on (localstorage persist data in case of version< 6? Have you try it?).
尝试设置/添加 android:allowBackup =您的manifest.xml中有false
和 android:fullBackupContent =false
。
这些属性可以在应用程序的manifest.xml中的< application />
中找到。
These properties can be found in <application/>
in application's manifest.xml.
这篇关于我在Android设备中卸载并安装了离子v1应用程序后,$ localStorage数据已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!