Answered: Best practices to save user settings locally
Answered: Best practices to save user settings locally
Hello!
Are there best practices when storing user settings locally in Sencha Touch? Example:
A simple, one user, app where the user can change some settings - like background color, text size etcetera.
Use case:
The user navigates to the settings view
The user changes some settings in an ordinary form
The user clicks save and the settings are persisted
So I would like to use local storage for this. Can I use the model layer with a LocalStorage proxy? The way I see it, there's only one Settings object: a singleton. How do I handle that?
you can check the count of the store and work with a record with the same ID, should be only one record in the store. so if no record exist create one otherwise work with the existing one
you can check the count of the store and work with a record with the same ID, should be only one record in the store. so if no record exist create one otherwise work with the existing one
Basically what it means is that the localstorage for WebViews (like phonegap and sencha) is now treated as a temporary store that can be cleared at any time by the OS. So do not trust it to remain after you application is closed.
Basically what it means is that the localstorage for WebViews (like phonegap and sencha) is now treated as a temporary store that can be cleared at any time by the OS. So do not trust it to remain after you application is closed.
Yeah I read about that in the Sencha blog. But if I understand it correctly theres no problem if my users add the app through Safari to the home screen?
I don't think so. The way I understood it is that localstorage is now stored under a "temporary" folder on the device regardless of its origin (WebView or home screen). This means that if the space is needed by some other application or website your data may be deleted. The spec unfortunately says little about persistence, but I seem to remember reading somewhere that Chrome will purge unused data if the space is needed. I may be wrong though.
By my understanding this doesn't totally rule out the use of localStorage. Phonegap 1.6 has come up with a solution whereby the location that localStorage records are kept is moved to a location that won't be deleted/cleaned up.
Yeah, but PhoneGap has done something actively to fix the issue. I think they move the localstorage file back to its old location or something like that. Sencha does not do that yet as far as I know. So if you are packaging with PhoneGap you should be OK, but using plain Sencha Touch will probably not work.