Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
About the Authors
About the Reviewers
Related Plugin Resources

Time for action – listing folders

Get ready to explore the folders of the device's persistent storage. Use the following steps:

  1. Open the command-line tool and create a new project using the Cordova CLI tool you installed before. This will create a new directory called FileSystem in your current working directory:

    $ cordova create FileSystem
  2. Move to the directory you just created:

    $ cd FileSystem
  3. Add the platforms you want to test on the device API. For this example, we add the Android platform:

    $ cordova platform add android
  4. Add the File API plugin using the following command:

    $ cordova plugin add cordova-plugin-file
  5. Go to the www folder, open the index.html file, and add a div element with the id value as fileslist inside the body of the app:

    <div id="fileslist"></div>
  6. We will now add a deviceready event listener in the JavaScript section. The onDeviceReady function has to be called once the deviceready event is fired:

    document.addEventListener("deviceready", onDeviceReady, false...