You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "yiharng (via GitHub)" <gi...@apache.org> on 2025/07/21 13:11:23 UTC

[I] When using an external SD Card in Android 15, there will be problems listing files in the directory [cordova-plugin-file]

yiharng opened a new issue, #650:
URL: https://github.com/apache/cordova-plugin-file/issues/650

   # Bug Report
   
   ## Problem
   
   The following code will cause an error in Android 15 when using an external SD Card
   
   ```javascript
   window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function()
   {
     window.resolveLocalFileSystemURL("file:///storage/0000-0000/Android/data/xxx.xxx.xxx.xxx/files",function(d)
     {
       d.createReader().readEntries(function(ok)
       {
          console.log("ok");
       },function(err)
       {
          console.log("err");
       });
     },errfunc);
   },errfunc);
   
   ```
   
   I modified FileUtils.java in the source code as shown below. After adding annotations, the program can run normally. However, this modification method is not ideal.
   
   ```javascript
   
           } else if (action.equals("readEntries")) {
               threadhelper(new FileOp() {
                   public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException, IOException {
                       String directory = args.getString(0);
                       String nativeURL = resolveLocalFileSystemURI(directory).getString("nativeURL");
   /*                    
                       if (needPermission(nativeURL, READ)) {
                           getReadPermission(rawArgs, ACTION_READ_ENTRIES, callbackContext);
                       } else {
   */                    
                           JSONArray entries = readEntries(directory);
                           callbackContext.success(entries);
   //                    }
                   }
               }, rawArgs, callbackContext);
   
   ```
   
   


-- 
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: issues-unsubscribe@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [I] When using an external SD Card in Android 15, there will be problems listing files in the directory [cordova-plugin-file]

Posted by "yiharng (via GitHub)" <gi...@apache.org>.
yiharng commented on issue #650:
URL: https://github.com/apache/cordova-plugin-file/issues/650#issuecomment-3096961730

   I have another SD Card for expansion inserted into my Android phone, and then I use ``` cordova.plugins.diagnostic.getExternalSdCardDetails ``` to get the path of this SD Card, so it is different from the externalApplicationStorageDirectory path. I found that I can write and read data in the expanded SD Card without any problems. Only when getting the file name in the directory will an error occur.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [I] When using an external SD Card in Android 15, there will be problems listing files in the directory [cordova-plugin-file]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #650:
URL: https://github.com/apache/cordova-plugin-file/issues/650#issuecomment-3096865310

   It's likely an issue with the [needPermission](https://github.com/apache/cordova-plugin-file/blob/master/src/android/FileUtils.java#L580) method.
   
   Note that since scoped storage, most paths in the external file system is not readable. The only path that should be readable via FS apis is `cordova.file.externalApplicationStorageDirectory`, which it sounds like is what you have, but our docs states the path starts with `/sdcard` while your example shows `/storage`.
   
   Are you able to confirm whether the `externalApplicationStorageDirectory constant matches `file:///storage/0000-0000/Android/data/xxx.xxx.xxx.xxx/files`
   
   If they don't match that's likely the root cause of the issue.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [I] When using an external SD Card in Android 15, there will be problems listing files in the directory [cordova-plugin-file]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #650:
URL: https://github.com/apache/cordova-plugin-file/issues/650#issuecomment-3096974101

   Yah so the file plugin assumes one path, and assumes you're using the constant, and it does a check based on that to determine if attempting read permission is necessary.
   
   But there are multiple ways on the filesystem to get access to the sdcard. `/sdcard` is just a symlink to `/storage/...` i believe.
   
   So I think the best course of action is to make sure that both `/sdcard/` and `/storage/` paths are used in the checks.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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