I dont seem to get the persistence of data in HTML5's localstorage in ios/android webviews. I am developing the HTML side of a hybrid app. To store data that is needed on my side, I use local storage. I do not clear the localstorage, I only read and write. But after a few tests, there are rare occurrence of localstorage being cleared. I tested this on other versions of android and ios, it's rare, but it still occurs and it is inconsistent. I tested the app in the same version of android 4.4( different phone models). There is no occurrence in the first one, the other one however, occurs after closing the app and opening it after a few hours. Same goes for ios. Am I the only one experiencing this problem?
3 Answers
I have never experienced anything like that. However, my advise to you is that you might attempt to read the data before it is successfully written. The another thing I could think of is that some how the url to your html is changed.
I assumed you use phonegap/cordova. You could download GapDebug to find out what happened to your data.
By the way, I made small lib for caching data. I used in my last hybrid app to store some user's data. If the problem is your wrapper for webview, It's useless. But if the problem is your js code, it might make your life easier.
Check it out here: cacheJS
Or if you want to read my blog: Cache your data with Javascript

- 398
- 2
- 12
I have observed issue like you said in a PhoneGap application.
You said that it is rare and inconsistent also it is occurs some times when you close your application and start it after few hours.
So it may be happens because of the cookies. I have seen in PhoneGap application that after some interval of time cookies are cleared or session has expired for both PlateForm. How ever it depends on the architecture of your application.
So check session expired time of application and also make sure that cookies are not cleared.

- 22,848
- 21
- 95
- 95
-
This makes no sense; local storage and cookies are different things. – Mark Amery Apr 03 '16 at 09:55