让我假设我在Android中有一个文件夹,它可能在内部或外部存储中:" vikas kohli"文件夹和我想检查" vikas kohli"是否有.mp4文件。那么如何使用Cordova检查一下?
预先感谢!
您需要使用文件插件。这里一些基本示例代码:
window.resolveLocalFileSystemURL(DIR_FULL_PATH, function(dirEntry) {
var directoryReader = dirEntry.createReader();
console.log(dirEntry);
// Get a list of all the entries in the directory
directoryReader.readEntries(success,fail);
});
function success(entries) {
var i;
for (i=0; i<entries.length; i++) {
//Here you can check the entries ofject for the file name and do stuff
console.log('En - ', entries[i]);
}
}
function fail(error) {
console.log("Failed to list directory contents: ", error);
}
引用文件插件:https://github.com/apache/cordova-plugin-file