localStorage not persisting on app rebuild with Java 8

Hi there,

I’ve been developing my app for 10 months and in all that time I’ve been using localStorage to persist user data. I know there are better options but it has served my purpose fine up to now.

I’m just developing for Android and I would write my code and then install onto my phone with ionic run android --device

The changes would be installed and my user data would still be there.

However, just today I needed to upgrade to use Java 8 rather than 7 in order to support the new Google Play Services (I think that’s what required it).

Now when I rebuild and reinstall the app with ionic run android --device all of my localStorage data is wiped and the app installs as if totally new.

Is this to be expected?
Is there something I can change to make it work like it did before?

Many thanks for any responses.

Potentially useful information:
$ ionic -version
2.0.0

$ java -version
java version "1.8.0_101"
Java™ SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot™ 64-Bit Server VM (build 25.101-b13, mixed mode)

$ cordova -version
5.4.0

OS
Windows 10

Android version (on phone)
6.0.1 - security patch 5 October 2016.
(Just updated today so potentially also a cause of the change)

Local storage can be erased out from under you at any time. Do not rely on it for data that must be persisted. Use SQLite.

Thanks for the response. You’re absolutely right, I should change to a more robust on-device storage solution.

However, that aside for the moment, the core issue I’m facing is the change of behaviour of the install on updating the app via “ionic run”.

It used to do an update install, which kept all local app settings, including, for example where I had placed the app icon on my phone homescreen. It now appears to do a completely fresh install every time - i.e. it completely removes the app and then reinstalls as a brand new app.

So, I’m wondering, is that expected behaviour?
Is it something I can change?

Many thanks.