1

In my application i used to show to the user all the files with a specific extension available in his "Downloads" directory :

File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
return dir.listFiles(new FilenameFilter() {
    public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".ext");
    }
});

It seems that this is not working anymore on android 11 and 10 (maybe below ?).

After investigation i found that listFiles() or list() now only return image file and not all the files as it used to be. Almost like if a "default filter" was applied. Therefore my ".ext" files doesn't show anymore

What can i do to be able to see my ".ext" file and not only image file ?

Note that using the standard Filepicker to choose a file is not really an option , i have to stay in the app workflow.

grunk
  • 14,718
  • 15
  • 67
  • 108
  • On an Android 10 device you can list all files. Extension does not matter. Owner does not matter. Need to request legacy external storage in manifest. – blackapps Jan 26 '21 at 16:34
  • 1
    On an Android 11 device you can list all file types. But now the owner matters. The app can list its own files of all types. And indeed image files from default camera app. – blackapps Jan 26 '21 at 16:36
  • Indeed files generated by my app are visible. But the all point of this file is to be exchanged between device or downloaded from a website. How application like file explorer proceed to list all the files ? – grunk Jan 26 '21 at 18:52
  • 1
    They got all files access requesting MANAGE_EXTERNAL_STORAGE: https://stackoverflow.com/questions/63842070/accessing-external-storage-in-android-api-29 – blackapps Jan 26 '21 at 19:10

0 Answers0