Cordova: How to get list of all Files/Directories in a directory?

function success(entries) {
    var i;
    for (i=0; i<entries.length; i++) {
        console.log('En - ', entries[i]);
function fail(error) {
    console.log("Failed to list directory contents: ", error);
// output in android: file:///storage/emulated/0/Sounds
var directory_path = cordova.file.externalRootDirectory+"Sounds";
window.resolveLocalFileSystemURL(directory_path , function(dirEntry) {
    var directoryReader = dirEntry.createReader();

    // Get a list of all the entries in the directory

Tested in Android.

Click here for more details.

Another linkĀ Mobile File Explorer with PhoneGap/Cordova has examples.

Leave a Reply

Your email address will not be published. Required fields are marked *