O'Reilly logo

PhoneGap 3 Beginner's Guide by Giorgio Natili

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 – reading and rendering an Image

Get ready to render the first available image in the device's storage into the PhoneGap default app template. Refer to the following steps:

  1. Open the command-line tool and create a new PhoneGap project named ReadingFile.
  2. Go to the www folder, open the index.html file, and add an img tag with the id value firstImage inside the main div of the app below the deviceready one.
    <img id='firstImage' /> 
  3. Go to the www/js folder, open the index.js file, and define a new function named requestFileSystem.
    requestFileSystem: function () { 
    
        // The request of access to the file system will go here
    
    }
  4. Define the error handler in order to get the code of every possible error.
    onError: function(error){ navigator.notification.alert(error.code, ...

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