localStorage data store time - javascript

I am using localStorage in jQM and PhoneGap. If I don't delete localStorage manually, how long would it be stored? When it is deleted?
I would like to know how it works on mobile devices running Android and iOS. I found an opinion that iOS browser clears it occasionally, is that true?

The localstorage is persistent. It will be stored until you uninstall the application or clear it manually.

Related

How to store data in android localstorage using JS

I'm using localStorage.setItem() for setting the data in the localstorage of my browser
but I don't know what is happening in my android browser the data is not getting saved in localstorage
localStorage.setItem("mytime", Date.now());
Yeah. The mobile browser also has localStorage & sessionStorage. Check Mozilla docs
Refer Can I Use? too...
If your data is not getting stored in localStorage of mobile devices. You could debug mobile devices by
Android -remote debugging.
iOS - remote web inspector

How to clear cache in Cordova/Phonegap app (without removing localstorage)

I have a Cordova app and I noticed that its size is increasing every time I navigate the section where there are many images (links from web and not stored on the device).
I think that the reason is that I need to clear webview cache (I use Crosswalk so the webview is based on chromium).
I search around but I can't find a way to clear only cache every time user exits the app.
I tried to run window.location.reload(true) on exit but it does not work.
Besides, I have found some plugins that do the job, but they remove all storage data (localstorage too) and I don't want that.
Could you help me with that?
Thanks

Will my apps lose localStorage data if Crosswalk updates it's internal browser?

Recently I adopted cordova's crosswalk plugin to ensure a uniform and performant HTML5 environment across android devices. Everything was working fine until I deploy the application. That's when I noticed that all existing settings from the native browser, which was being used by the cordova webview were gone! Our localStorage was now in a different browser - the chromium browser which is served by crosswalk project.
Now I'm asking myself what will happen if the crosswalk project updates it's internal browser to a new chromium browser version? Will I lose the localStorage data once again?
Here are some references that I had look at while researching into the subject:
Crosswalk storage limits
Scope of sessionStorage and localStorage
Where the sessionStorage and localStorage stored?
Probably yes, you will lose the data. Also updating the device SO can cause the loss of data. I had the same problem. You should consider to use sqlite database to persist permanently your data.
The issue that was concerning this subject was closed last week. "Not able to migrate the existing webview data (localstorage/websql) to crosswalk"
Check it out here: https://crosswalk-project.org/jira/browse/XWALK-7368

localStorage vs localSettings

I'm trying to save settings in a Javascript Based Universal App in Windows 10.
I'm currently using localStorage and it seems to be working fine. But I've seen other posts that indicate I should use:
Windows.Storage.ApplicationData.current.localSettings
(see: Best way to store string array in local storage, Windows 8?)
And this works as well.
But I'm wondering what is the recommended way? localStorage seems to be persistent even when I quit and reload the app. But will it always be persistent? And will it work on mobile? or is localSettings generally the way to go, what's the difference here guys?
ApplicationData.current.localSettings is backed up in the cloud, which means that if the user buys a new phone (or resets their existing phone) and asks to restore settings from a backup of their old phone, the settings in ApplicationData.current.localSettings will be restored to the new phone. This article discusses app data backup in more detail.

Javascript to store value until cache is cleared?

I am using the following to save a random value in the local storage that will stay until the cache is cleared
localStorage['mkey1'] = Math.floor(Math.random()*801);
however when on mobile devices this does not work if the user closes the browser app, the cache is deleted. This of course is a result of the problem that the cookies in mobile devices are more like session cookies rather the desired expiration date I set to the cookie.
I have came across different sources like
https://danq.me/2012/04/24/visitor-tracking-without-cookies/
and
http://robertheaton.com/2014/01/20/cookieless-user-tracking-for-douchebags/
but I want to use plain Javascript, no Sinatra.
Local Storage should persist on all browsers until it is cleared, unless the browser doesn't support it; are you using a supported browser on the mobile devices you are testing? http://caniuse.com/#search=localstorage

Categories

Resources