Reputation: 41
i want to read files from external directory, but cordova.file.externalRootDirectory always returns the internal device memory "file:///storage/emulated/0/" ???
Upvotes: 1
Views: 1609
Reputation: 1128
Insert legacy application external storge on file config.xml
<application android:requestLegacyExternalStorage="true" />
Upvotes: 0
Reputation: 30366
The getExternalSdCardDetails() method of cordova-diagnostic-plugin can be used to get a reference to removable micro SD card locations:
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);
});
Upvotes: 0
Reputation: 1
plese follow the link I hope you will find solution in this link https://www.raymondcamden.com/2014/07/15/Cordova-Sample-Reading-a-text-file
Upvotes: 0