Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Displaying the contents of a directory


As devices may offer us a lot of storage space that we can potentially use, we can make sure that we have the ability to traverse the filesystem to ascertain the structure of the storage available.

How to do it...

In this recipe, we will build an application that will read the contents of a directory from the device's root filesystem, and display it in a list format:

  1. Firstly, create a new PhoneGap project named showdirectory by running this line:

    phonegap create showdirectory com.myapp.showdirectory showdirectory
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:

    cordova platform add ios
    cordova platform add android
    
  3. Add the file plugin by running the following line:

    phonegap plugin add org.apache.cordova.file
    
  4. We're going to use jQuery Mobile. So, we'll include the reference to the JavaScript and CSS files within the head tag.

  5. Open www/index.html and clean up the unnecessary elements. So, we will have this:

    <!DOCTYPE html>
    <html...