YasZe
YasZe

Reputation: 41

problems with cordova.file.externalRootDirectory

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

Answers (3)

Edvan Souza
Edvan Souza

Reputation: 1128

Insert legacy application external storge on file config.xml

<application android:requestLegacyExternalStorage="true" />

Upvotes: 0

DaveAlden
DaveAlden

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

John Harris
John Harris

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

Related Questions