简体   繁体   中英

When Cordova app is reinstalled or updated from Google Play, is localStorage cleared?

I have a Cordova app on Google Play that utilizes localStorage . In the new version of it, the same keys are used, but the expected values are different. This means that if an old value is encountered, there may be problems.

An obvious solution is to have a version variable that tracks the app's version. If the stored value is the same as the app's current version, do nothing, else update the value and clear localStorage .

However, is that even needed? I have noticed that when I reinstall the app for debugging purposes, localStorage is sometimes cleared.

Does an update on Google Play guarantee fresh localStorage ?

When exactly is localStorage cleared?

On both Android and iOS, local storage values are preserved if the app is updated but not if the app is reinstalled (first uninstalled then installed).

Note that on iOS, local storage of a Cordova app may also be cleared at any time if the device runs low on space - Apple considers it to be a local cache.

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