Skip to content

Cannot read files under cordova.file.externalRootDirectory for Android 11 #494

@janetcasarez

Description

@janetcasarez

Bug Report

Cannot read files under cordova.file.externalRootDirectory for Android 11

Problem

Getting ready for move to Android 11 and new folder locations. I need to move my app user files from old location into new location.
My old location for user files is cordova.file.externalRootDirectory/crossstitch.
New location will be cordova.file.externalRootDirectory/Android/data/com.crochetdesigns.crossstitch/.
However, when I set and in config.xml, I can not read the files under old folder to move them. I assume the change deadline is still Nov 1 2021. Then all apps need to target 30.

If I do an update now and leave it targeted to 29 all is good. But that does not leave users enough time to update the app, use the app to get files moved before Nov 1 deadline. I have been trying to solve this problem for over a month now. I have 11 apps in the playstore that I will need to do this for.

What is expected to happen?

Allow apps targeted for 30 to read all files under cordova.file.externalRootDirectory.

What does actually happen?

can only read my .png files under cordova.file.externalRootDirectory/crosssstitch folder

Information

Command or Code

Test code below:

var movePatFiles = {

movePatFiles: function () {
// old location of files
try {
window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, movePatFiles.feMovePattFiles, movePatFiles.moveFail);

    }
    catch (error) {
        alert(error);
    }
},

feMovePattFiles: function (fileSystem) {
// folder already exists
try {
fileSystem.root.getDirectory("crossstitch", { create: true, exclusive: false }, movePatFiles.feMovePatternFiles, movePatFiles.moveFail);
}
catch (error) {
alert(error);
}
},
feMovePatternFiles: function (directoryEntry) {

    // read from cordova.file.externalRootDirectory + "crossstitch" + "/"
    // read all the files in the folder
    var reader = directoryEntry.createReader();
    reader.readEntries(movePatFiles.getPatFileList, movePatFiles.moveFail);
},

getPatFileList: function (entries) {
var patFiles = [];
for (var i = 0; i < entries.length; i++) {

        // only finds my .png files
         alert (entries[i].name);
        
    }
    return patFiles;
},

moveFail: function (error) {
alert("fail");

}

}

Environment, Platform, Device

Android 11 only.

Version information

cordova version 10.0.0
cordova-plugin-file 6.0.2 "File"

Checklist

  • [ x] I searched for existing GitHub issues
  • [x ] I updated all Cordova tooling to most recent version
  • [ x] I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions