WHAT YOU WILL LEARN IN THIS CHAPTER:
- Learning about storage options
- Using the Database object
- Using the localStorage object
- Learning about options and arguments
Up until now, you’ve been working with parts of the PhoneGap API that deal with the accelerometer, the compass, the camera, and other device-specific capabilities.
In this chapter, you learn how to use HTML5 storage options directly in your code. The PhoneGap API has support for both web SQL databases and the local storage option. You learn how to use each of them here.
LEARNING ABOUT STORAGE OPTIONS
If you’re coming from the world of PHP, Rails, or Django development (to name just a few), then you’re used to building web applications that store their data in some kind of database (most likely, mySQL).
Furthermore, if you’ve been doing any HTML5 development, you’ve probably run into the database options available on the client side. For the first time, PhoneGap developers are able to create client-side applications that use a somewhat reliable database back end.
For example, if you use Chrome or Safari to visit html5demos.com/database, you will see the page fill up with tweets. Now, at first glance, this page appears to be powered by a traditional database like mySQL. But if you right-click the page and click Inspect Element, you’ll see something similar to Figure 11-1.
If you click the Resources tab and then scroll down to the databases portion, you ...