janetcasarez opened a new issue #494:
URL: https://github.com/apache/cordova-plugin-file/issues/494


   # 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 <preference name="AndroidPersistentFileLocation" 
value="Compatibility" />and <preference name="AndroidPersistentFileLocation" 
value="Compatibility" /> 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
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   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
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   Android 11 only. <preference name="android-targetSdkVersion" value="30" />
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   cordova version 10.0.0
   cordova-plugin-file 6.0.2 "File"
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [ 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to