You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/08/16 08:41:02 UTC

[GitHub] phil4literacy opened a new issue #239: Not seeing files that are stored on the Android device

phil4literacy opened a new issue #239: Not seeing files that are stored on the Android device
URL: https://github.com/apache/cordova-plugin-file/issues/239
 
 
   The issue has been described in this question: 
   https://stackoverflow.com/questions/42490558/not-seeing-files-that-are-store-on-the-android-device-using-cordova-file-plugin
   
   I'm facing the same issue and was only able to solve it by downgrading to Android API 22 as the author in the Stackoverflow question did. 
   
   When looping through all directories on the phone, it will only see files in the directory where the app is stored, but not files stored for example in the download folder of the SD Card.
   
   This is my function:
   function loopThroughDirectories(localURLs, callback) {
         for (i = 0; i < localURLs.length; i++) {
   
           console.log("directory: " + localURLs[i]);
           if(i == (localURLs.length - 1))
           {
             loading.dismiss();
             callback();
           }
           if (localURLs[i] === null || localURLs[i].length === 0) {
             continue; // skip blank / non-existent paths for this platform
           }
           window.resolveLocalFileSystemURL(localURLs[i], addFileEntry, addError);
         }
       }
   
   var that = this;
       var addFileEntry = function (entry) {
         console.log("addFileEntry");
         var dirReader = entry.createReader();
         dirReader.readEntries(
           function (entries) {
             console.log("nr of entries: " + entries.length);
             var i;
             for (i = 0; i < entries.length; i++) {
               console.log(entries[i].fullPath);
               if (entries[i].isDirectory === true) {
                 // Recursive -- call back into this subdirectory
                 addFileEntry(entries[i]);
               } else {
                 if(entries[i].fullPath.endsWith(".apkg") && entries[i].fullPath.search("/AnkiDroid/") == -1)
                 {
                   console.log(i + ": " + entries[i].fullPath);
                   that.arrFiles.push({nr: i, fullPath: entries[i].fullPath, nativeURL: entries[i].nativeURL}); 
                 }
               }
             }
           },
           function (error) {
             console.error("readEntries error: " + error.code);
           }
         );
       };
   
   It's used in this project for finding all files on a phone with the apkg extension:
   https://github.com/phil4literacy/TeachMeWords

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org