I'm writing a HTML5 application that I want to release on the iOS app store. Either using PhoneGap or wrapped in a UIWebView control.
I'm a bit confused about what options I have in terms of storing data for my application.
Are using localStorage, WebSQL or IndexedDB technologies appropriate for storing application data in this type of application? I will be storing JSON and XML data.
Keep in mind, if the user inadvertently deletes this data then they will have lost their work, which obviously I don't want to happen.
I understand that the only real way to alleviate this risk is to sync the data to the "cloud" or other online system - I can do that in a future release, but not right now. Initially I just want to store the data locally if that is a reasonable stable way to do things.
From what I understand, when clearing the cookies the browser will also clear any localStorage data. So that rules that out, as I can see users doing that by accident.
WebSQL looks pretty good - the user can't inadvertently delete it on iOS. They would actually have to go into the browser settings and delete the database manually.
But the downside of WebSQL is that it may not be supported in the future from what I've read.
With IndexedDB, I am not clear when that data gets cleared. Will it also removed when cookies are deleted, or does the "databases" option in the Safari settings control this?
Is IndexedDB the better solution, as it will have better support than WebSQL in the future?
Are there other solutions that are more appropriate that I am not aware of?
If you are wrapping in PhoneGap (or AppMobi - where I work), you're data is segmented to that app. A user can not go into Safari and clear the browser data/cookies and have that happen in your app. The only way they can delete it is by deleting the app.
I don't think IndexedDB is avaiable. Window.localStorage is (5 megs but I think it can grow), which is a KVP system.
I don't see them dropping WebSQL for a few years. The HTML5 spec isn't even ratified yet, so things could change again.
Since you are just storing strings, you can check out libraries like Lawnchair that will use different adapters (localStorage, WebSQL, etc) to store your data how you want since it appears you do not have complex data sets.