I write a file to Environment.DIRECTORY_DOWNLOADS, why can't I see it via the Downloads App?

The Downloads app only shows downloads downloaded via DownloadManager, not all files in the directory.


In case anyone wonder how to do this, I found the answer here

To allow the System to display you file in the "Downloads" App, you need to explicitly notify the DownloadManager that a download as been completed by using the method addCompletedDownload()

By using it, the system will allow your Download App to display the file you have created yourself.

Hope it will help.

UPD: This method was deprecated in API level 29.


you just created File instance like

File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(path, "db.csv");

but the file "db.csv" is not created yet. use

file.createNewFile();

to create the file "db.csv" really...

Tags:

Android