O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

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

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 ...

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