Also, how to test if the browser in device supports local storage?
With web storage, web applications can store data locally within the user's browser. Before HTML5, application data had to be stored in cookies, included in every server request. Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance.
Local storage is part of the HTML5 Web Storage API and it allows you to store data in the browser. Unlike cookies, data stored using local storage isn't sent back to the server. All data stays on the client, and you can currently store from 2MB to 10MB.
In HTML5 there are two types of web storage API. localStorage: It is used to store data on the client-side. It has no expiration time, so the data in the LocalStorage exists always till the user manually deletes it.
When using the local storage, you should consider the following: Validate that the local storage is available. This is available on browsers that support HTML5 and IE8+. Devices like IPhone, Android and BlackBerries support HTML5.
I would say that HTML5 storage is supported since API Level 7 (2.1) because the method that enable it in WebSettings
Object says it here, but I think I'm using it on the Native browser since Android 2.0.
// Javascript Test
if (typeof window.localStorage == 'object')
{
// localStorage is supported
}
else
{
// localStorage is not supported
}
http://jsfiddle.net/kcckq/
Here is a blog post that tells us that is Android 2.1+
Here is another article that is saying it's Android 2.0+ and giving an example on how detecting if localStorage is supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With