简体   繁体   中英

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM