Reputation: 309
i was using phonegap's file to list all the folders inside the phone using this code.
document.addEventListener("deviceready", makeFileSystemReady, true);
var globalFileSystem;
function makeFileSystemReady(){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemError);
}
function onFileSystemSuccess(fs){
globalFileSystem=fs; //Initialized the global file system.
}
function onFileSystemError(){
console.log("Unable to load the file System Plugin");
}
function chooseFromGallery(){
var dirReader = globalFileSystem.root.createReader();
dirReader.readEntries(galleryFiles,galleryFilesErrors);
}
function galleryFiles(entries){
var s = "<p style='color:white'>";
console.log(globalFileSystem.root);
for(var i=0,len=entries.length; i<len; i++) {
//entry objects include: isFile, isDirectory, name, fullPath
s+= entries[i].fullPath;
if (entries[i].isFile) {
s += " [F]";
}
else {
s += " [D]";
}
s += "<br/>";
}
s+="<p/>";
document.getElementById('videoArea').innerHTML=s;
}
function galleryFilesErrors(){
alert("Unable to use the file system !");
}
This code is working fine, but the problem here is, how can i get the list of folders inside my SD Card or External Storage of my Phone.
Upvotes: 0
Views: 387
Reputation: 1029
The documentation for the cordoba-plugin-file has the identifiers for the different locations.
https://github.com/apache/cordova-plugin-file
In this case you want to use cordova.file.externalRootDirectory which will resolve to the right directory entry when you pass it to window.resolveLocalFileSystemURL().
Upvotes: 1