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:
- Firstly, create a new PhoneGap project named
showdirectory
by running this line:phonegap create showdirectory com.myapp.showdirectory showdirectory
- Add the devices platform. You can choose to use Android, iOS, or both:
cordova platform add ios cordova platform add android
- Add the
file
plugin by running the following line:phonegap plugin add org.apache.cordova.file
- We're going to use jQuery Mobile. So, we'll include the reference to the JavaScript and CSS files within the
head
tag. - Open
www/index.html
and clean up the unnecessary elements. So, we will have this:<!DOCTYPE html...