O'Reilly logo

PhoneGap by Andrew Lunny

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Caching stories in a local database

Since the interface for using Web SQL is quite verbose, we're going to create a separate JavaScript file to hold all of our database specific code.

  1. Create a file called database.js and add a reference to it in your index.html:
    <script src="phonegap.js"></script>
        <script src="xui.js"></script>
        <script src="mustache.js"></script>
    <script src="database.js"></script><script src="app.js"></script>

    The first thing we need to do when using Web SQL is get a reference to our database, using the openDatabase function:

    // open the database function initializeDB() { var localDatabase = openDatabase( "internetNews", // short name "1.0", // version "News From The Internet", // long name 5000000 // maximum size ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required