1

Currently I am working a project where I have to get access to the Music directory which can be found in the Root. I am trying to get the directory with the Phonegap/Cordova plugin: https://github.com/apache/cordova-plugin-file

I tried many things and I did research on Google but couldn't find anything good.. Here is my code:

/* THIS IS PLACED IN THE onDeviceReady FUNCTION! */        
window.requestFileSystem(window.TEMPORARY, 1024*1024, onFileSystemSuccess, function(e) { alert("Something went wrong.."); });
alert( "5" );
/*************************************************/

    function onFileSystemSuccess(fileSystem) {
        alert("6"); // just for testing
        fileSystem.root.getDirectory("Music", {}, getDirSuccess, function(e) { alert("Doesn't work"); } );
    }

    function getDirSuccess(dirEntry) {
        alert("7");
        var directoryReader = dirEntry.createReader();
        directoryReader.readEntries(readerSuccess,fail);
    }
I wrestled a bear once.
  • 22,983
  • 19
  • 69
  • 116
247errorsnl
  • 157
  • 12

2 Answers2

1

Hmm... you might want to try window.resolveLocalFilesystemURL() instead of window.requestFilesystem() if you're looking to read the filesystem.

I've got a sample routine that iterates through a bunch of directories here: How to get documents in an android directory that PhoneGap will see. It might help narrow your search.

eb1
  • 2,897
  • 3
  • 31
  • 42
0

Try the following path :

/android_asset/www/song.mp3
solimanware
  • 2,952
  • 4
  • 20
  • 40