localStorage not persisting on Android 5.0.1, Cordova 3.7.0.

208 views
Skip to first unread message

Nathan Sutherland

unread,
Apr 29, 2015, 3:50:46 PM4/29/15
to phon...@googlegroups.com
This just started happening on a Android 5.0.1 device with Cordova 3.7.0. With debug turned on in the app, issuing "window.localStorage.setItem('test','result'); console.log(window.localStorage.getItem('test'));" correctly shows 'result'.

Then I force the app to close and start it up again. Issuing "console.log(window.localStorage.getItem('test'));" now returns NULL instead of 'result'.

No .clear() calls are being made.

Oddly, prior values in localStorage (from before the update) are still present. Just NEW VALUES are forgotten.

Are there any known issues with localStorage persistance on Android 5.0.1 and Cordova 3.7.0?

Nathan Sutherland

unread,
Apr 29, 2015, 5:58:44 PM4/29/15
to phon...@googlegroups.com
Update: If I leave the app open (do not force close it) for 2 hours, then the value is actually saved to localStorage, and a reboot of the app picks up the saved value.

But of course if I update the value to a NEW value then force close the app, the new value is forgotten and the old one remains.

I'll do some testing to see what the minimum time required is to save localStorage values to the internal memory.

This is on a LG G3 (VS985 4G)

Tom

unread,
Apr 30, 2015, 9:08:06 AM4/30/15
to phon...@googlegroups.com
Hi,

There is an issue with the webview of chrome (v 42/43):

Let me know if you find a workaround for this issue.

Nathan Sutherland

unread,
Apr 30, 2015, 11:46:13 AM4/30/15
to phon...@googlegroups.com
Thanks Tom!

(for everyone else) The link shows that they started doing RATE LIMITING on the flushing, so it writes to the disk every 10 min instead of every second. This really hurts the reliability of localStorage for use on mobile devices right now. Hopefully they will remedy this in an update or two of Chroimium.

Some users on stackOverflow have switched to using indexedDB.

My workaround currently is to call my function which writes to localStorage just prior to using the many functions which grab data from localStorage. I'm hoping for a fix from Chromium within the next couple builds, or I too will be switching away from localStorage.
Reply all
Reply to author
Forward
0 new messages