How to clear localStorage when updating an app in webOS?

663 Views Asked by At

I am setting a value in localStorage while running the app. The working of this app is based on the value being set in localStorage. Exiting the app or rebooting the device does not cause any change in the data being stored in localStorage. This value is cleared when the app is manually removed. The value is again being set after installing and executing the app. This is fine. But the problem is the value is not being cleared if I re-install the app without removing. It takes the old value from localStorage. How to clear the localStorage when updating the app? Please help

1

There are 1 best solutions below

0
On

I would suggest that you store the version number of the app (or a version number corresponding with a data model version) and compare that on app startup. When your app starts, compare the data in local storage against the new version number and clear values when they are outdated.