$localStorage data already there after I uninstalled and installed the ionic v1 app in Android device

故事扮演 提交于 2019-12-23 04:41:32

问题


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.

I am also using cordova-plugin-crosswalk-webview version 2.2.0

Other information:

  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.

Thank you!


回答1:


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

Another solution is, when the app starts in app.js you can add this code:

  $window.localStorage.clear();
  $ionicHistory.clearCache();
  $ionicHistory.clearHistory();

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.

From the other hand Android 6 has automatic backup on (localstorage persist data in case of version< 6? Have you try it?).

Try setting/add android:allowBackup="false" and android:fullBackupContent="false" in your manifest.xml.

These properties can be found in <application/> in application's manifest.xml.



来源:https://stackoverflow.com/questions/41867189/localstorage-data-already-there-after-i-uninstalled-and-installed-the-ionic-v1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!