Chapter 7. IndexedDB
There are many different kinds of persistent storage that Cordova apps can use. Which storage mechanism you use depends largely upon the storage needs of your application. Furthermore, your app isn't restricted to a single type of storage. It might make the most sense to store user preferences in localStorage
and larger files using the File API. On the other hand, neither localStorage
nor the File API provides a simple mechanism for storing, retrieving, and searching structured data. You can use them for these purposes, of course, but you'll have to do most of the hard work yourself.Two storage mechanisms come to our rescue so that we don't have to reinvent the wheel. The older (and now deprecated) standard, Web SQL Database, uses a relational data model typical of databases such as Oracle, PostgreSQL, Microsoft SQL, and so on. A newer standard called IndexedDB (short for Indexed Database) uses key-object storage. This is particularly useful...