Disturbing news: as of 5.0.1, iOS destroys localStorage and localDb

282 views
Skip to first unread message

Wytze

unread,
Mar 22, 2012, 11:55:38 AM3/22/12
to persistence.js
I just got word that localStorage and localDb data are no longer
persistent in iOS as of version 5.0.1. The files have been moved to a
location in cache which is regularly cleaned.

I am still wrapping my head around what this means for my app and for
my use of persistenceJS. First thought is that there is no rescue,
since even saveToLocalStorage won't help now.

Anyone with a more optimistic perspective, or should I now switch to
indexedDb for good?

Link:
http://groups.google.com/group/phonegap/browse_thread/thread/4490b6a80f6c0e7c/9d08dbf4308564e9?lnk=raot

Kind regards,

Wytze

Neville Franks

unread,
Mar 22, 2012, 3:21:41 PM3/22/12
to Wytze
My understanding is Persistence.js uses the WebSQL Database which in
turn uses SQLite. I don't see how localStorage or localDb effects this.

Friday, March 23, 2012, 2:55:38 AM, you wrote:

W> I just got word that localStorage and localDb data are no longer
W> persistent in iOS as of version 5.0.1. The files have been moved to a
W> location in cache which is regularly cleaned.

W> I am still wrapping my head around what this means for my app and for
W> my use of persistenceJS. First thought is that there is no rescue,
W> since even saveToLocalStorage won't help now.

W> Anyone with a more optimistic perspective, or should I now switch to
W> indexedDb for good?

W> Link:
W> http://groups.google.com/group/phonegap/browse_thread/thread/4490b6a80f6c0e7c/9d08dbf4308564e9?lnk=raot

W> Kind regards,

W> Wytze

--
Best regards,
Neville Franks, Author of Surfulater - Your off-line Digital Reference Library
Soft As It Gets Pty Ltd, http://www.surfulater.com - Download your copy now.
Victoria, Australia Blog: http://blog.surfulater.com

Zef Hemel

unread,
Mar 23, 2012, 3:40:32 AM3/23/12
to persis...@googlegroups.com
If you read the linked post it also talks about WebSQL. Its data will still be persistent, but may be cleaned up whenever required. Effectively, on iOS, WebSQL is now a structured caching solution. Indeed disturbing. The only solution I see is sync. Sync your data to a server regularly and restore if necessary. If you don't store a lot of data you can use persistence.dump to create a large JSON object you could send to the sever and easily persistence.load again later. 

But yeah. This kind of sucks. 

-- Zef

Sent from my iPhone.

Sudhakar Fomra

unread,
Mar 23, 2012, 4:05:41 PM3/23/12
to persis...@googlegroups.com
The phonegap SQLitePlugin (https://github.com/davibe/Phonegap-SQLitePlugin) stores the DB file in the app's persistence storage location.... 

This brings me to a question for Zef... How difficult/easy would it be to modify persistence.js (for people who are already using it in their projects) such that persistence.js uses this DB file insted of the file stored in the cache (in iOS 5.1 and above)??? I'll be looking into it as well... but Zef you would be the right person to tell this...

Zef Hemel

unread,
Mar 25, 2012, 8:20:25 AM3/25/12
to persis...@googlegroups.com
It looks like the API is compatible with WebSQL, so I'd say it wouldn't be difficult at all. Just requires copying and adapting the WebSQL store a little bit. 

-- Zef

Sent from my iPhone.

Sudhakar Fomra

unread,
Mar 25, 2012, 8:29:03 AM3/25/12
to persis...@googlegroups.com
True dat, did some digging and supposedly the only difference in the websql and phonegap sqlite plugin apis is this

in WebSQL : result.rows.item(0)
in the phonegap plugin : res.rows[0]

and there is a bridge for this as well...


Call this tx.execteSql, and only other change that then needs to be made is to use the plugin to instantiate/create the DB.

-SF.
Reply all
Reply to author
Forward
0 new messages