How to store files generated from app in “Downloads” folder of Android?

I am generating an excelsheet in my app which when generated should be automatically saved in the “Downloads” folder of any android device where all the downloads are typically saved.

I have the following which saves the file under “My Files” folder –

File file = new File(context.getExternalFilesDir(null), fileName);

resulting in –

W/FileUtils﹕ Writing file/storage/emulated/0/Android/data/com.mobileapp/files/temp.xls

I rather want to save the generated file automatically in the “Downloads” folder when the excel sheet is generated.

Update # 1: Please see the snapshot here. What I want is the one circled in red and what you suggested gets stored in the one circled blue (/storage/emulated/0/download) if that makes sense. Please advise on how I can save a file in the one circled red i.e., “Downloads” folder which is different from /storage/emulated/0/Download under “MyFiles”


Use this to get the directory:


And don’t forget to set this permission in your manifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>