In the context of mobile applications it allows each application to have its own SQL database to work with. SQLite is basically an embedded SQL database. Local storage is super simple to use and doesn’t require installing anything, but it is very basic and not 100% reliable. If you wanted to store an object or array in local storage you would first need to convert it to a JSON string, and then when you retrieve it later you can decode that JSON string back into an array or object. One important thing to keep in mind when using local storage is that it can only store strings. This is the native way to set and retrieve local storage data, but some frameworks have their own inbuilt ways to access local storage. ![]() setItem ( 'someSetting', 'off' ) var someSetting = localStorage. Local Storage is a simple key-value system, let’s take a look at how you might go about setting and retrieving data: localStorage. If you are just using local storage to cache data from a server it would also not be a big issue if the data is lost since it can just be fetched from the server again. This would allow you to create a “Remember Me” type feature, but if the data is lost it’s not really a big deal because the user will just need to enter in their username and password again. One example of where local storage might be a suitable option is if you wanted to store something like a temporary session token. In general, you should only use it where data loss would not be an issue, and it shouldn’t ever be used to store sensitive data since it can be easily accessed. I think the browsers local storage can be a viable option and it is reasonably stable and reliable, but, it is possible for the data to be wiped, which means for a lot of applications it’s not going to be a great option. Local storage gets a bit of a bad wrap, and is generally considered to be unreliable. ![]() This is the most basic storage option available, which allows you to store up to 5MB worth of data in the users browser. There’s actually quite a few different options out there, and it can be pretty confusing, so in this article I will provide a brief overview of the different storage options, with quick examples and a summary of when you might want to use each one. These options might not be ideal for reasons which we will go through in this article, but we can also access native data storage by using PhoneGap which can overcome the shortfalls of browser based data storage. We do still have access to the usual browser storage options that websites have access to though like Local Storage, Web SQL (deprecated) and IndexedDB. HTML5 applications run in the browser, so we don’t have access to the storage options that native applications do. We want to sync online and offline data so that the user can continue using the application even when they are offline ( Evernote is a good example of this).We could skip unnecessary calls to a server by caching other data locally. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |