问题
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