Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
82 views
in Technique[技术] by (71.8m points)

android - Listing files in Downloads directory is limited to images

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.

question from:https://stackoverflow.com/questions/65904491/listing-files-in-downloads-directory-is-limited-to-images

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...