我想从外部目录中读取文件,但cordova.file.externalRootDirectory总是返回内部设备内存" file:/// storage / emulated / 0 /" ???
答案 0 :(得分:0)
请点击链接,希望您能在此链接中找到解决方案https://www.raymondcamden.com/2014/07/15/Cordova-Sample-Reading-a-text-file
答案 1 :(得分:0)
getExternalSdCardDetails()的cordova-diagnostic-plugin方法可用于获取可移动微型SD卡位置的参考:
cordova.plugins.diagnostic.getExternalSdCardDetails(function(details){
details.forEach(function(detail){
if(type === "application"){
console.log("Writable?" + detail.canWrite); //TRUE
cordova.file.externalSdCardApplicationStorageDirectory = detail.filePath;
// Write files to external SD card using this
}else{ // type === "root"
console.log("Writable?" + detail.canWrite); //FALSE
cordova.file.externalSdCardRootDirectory = detail.filePath;
// Read files from external SD card root using this
}
});
}, function(error){
console.error(error);
});