1

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!

coder
  • 8,346
  • 16
  • 39
  • 53
  • What OS are you using in your device that runs the app?All the data from localstorage are there or just some cached data?Also which version of ionic are you using? – e7lT2P Jan 26 '17 at 08:37
  • @Antonis I am using Android 6.0 Marshmallow. My ionic version is ionic 1. I had stored some login details. and search histories in localstorage all those are still there. I am using visual studio 2015 to build the ionic app. When I build the app in debug mode and after I uninstalled and installed the app again using debug mode that issue is not there, but when I witched to release mode again issues is there – coder Jan 26 '17 at 09:59
  • Please see my answer and let my know if this solves your problem. – e7lT2P Jan 26 '17 at 10:01

1 Answers1

7

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.

e7lT2P
  • 1,635
  • 5
  • 31
  • 57