[英]how to get list of folders of phone's sdcard(External Memory Card) in phonegap
i was using phonegap's file to list all the folders inside the phone using this code. 我正在使用phonegap的文件使用此代码列出电话内的所有文件夹。
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. 这段代码可以正常工作,但是这里的问题是,如何获取SD卡或手机外部存储中的文件夹列表。
The documentation for the cordoba-plugin-file has the identifiers for the different locations. cordoba-plugin-file的文档包含不同位置的标识符。
https://github.com/apache/cordova-plugin-file 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(). 在这种情况下,您要使用cordova.file.externalRootDirectory,当将其传递给window.resolveLocalFileSystemURL()时,它将解析为正确的目录条目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.