Android 11 save file to Download folder

Due to storage restrictions applied by Google, your downloaded files/folders get stored on your internal storage by default. Once the data is downloaded you can move it to your preferred folder on the SD card.

Google keeps changing the way apps can access shared files by adding and lifting restrictions to existing APIs to the point they had to write this.

The following is a simplified guide about the storage options of an app and how they differentiate between Android versions.

TLDR: not much have actually changed if you’re making a camera app. If you have a gallery or file app, then you have to do some refactoring.

In Android, an app has access to:

  1. private folders that only the app can see: getFilesDir(), getCacheDir() .
    /data/user/0/<package_name>/files
    /data/user/0/c<package_name>/files
  2. app-specific folders that other apps can see. There is a generic one: getExternalFilesDirs() and a media one: getExternalMediaDirs(). These are deleted when the app is deleted. These directories have 2 variants:
    1. those that exist in internal storage. You can get the path using the first element in the array returned by the aforementioned methods. /storage/emulated/0/Android/data/<package_name>/files
    /storage/emulated/0/Android/media/<package_name>

    2. those that exist in external storage such as SD card. You can get the path using the second element in the array returned by the aforementioned methods.
    /storage/11EC-2402/Android/data/<package_name>/files
    /storage/11EC-2402/Android/media/<package_name>
  3. public folders that all apps can see, like DCIM, Music, Download folder etc. They can be selected by the user by starting an ACTION_OPEN_DOCUMENT_TREE intent. These directories have 2 variants:
    1. those that exist in internal storage. Another (deprecated) way to get the path to these folders is with getExternalStoragePublicDirectory().
    /storage/emulated/0/DCIM
    getCacheDir()0
    2. those that exist in external storage such as SD card.
    getCacheDir()1

Note that the paths above are examples and should not be used as is.

All Android versions can write to 1, 2.1, 2.2 using the classic Files API.

Android 10 requires asking user permission for getCacheDir()2, as usual, and setting getCacheDir()3 to the manifest to access 3.1 using Files API. You can write whatever filetype you want in these folders and also delete pre-existing files or files created by other apps. 3.2 can’t be accessed this way.

Android 11 can write to 3.1 and 3.2 (no manifest flag needed) as long as the file type written matches the directory. For example, you can’t write a getCacheDir()4 file in getCacheDir()5 folder. In getCacheDir()6 folder, you can write whatever you want. Your app can delete only files created by it. It can’t delete pre-existing files or file created by a previous installation of the app. It can read files created by other apps. You can’t write to a random folder in the internal storage such as getCacheDir()7 but you can read its contents.

Note that in Android 11 you don’t even have to declare getCacheDir()2 in your manifest or ask user permission in order to write to all the aforementioned folders. If you want to read files created by other apps though, you’ll have to ask the user for getCacheDir()2 or /data/user/0/<package_name>/files
/data/user/0/c<package_name>/files
0 permission.

How do I find my Download folder on Android 11?

How to find downloads on your Android device.
Open the Android app drawer by swiping up from the bottom of the screen. You can also access the app drawer by tapping its icon on the home screen..
Tap My Files (or File Manager). Open your Android device's file manager app. ... .
Inside the My Files app, tap Downloads..

How do I copy files to data folder in Android 11?

Edit Files In Data Folder (Android 11 & 12).
Navigate to Data Folder. Using QuickEdit built-in file explorer to locate the data folder under internal storage, the path is similar as: /storage/emulated/0/Android/data..
Grant Permission to Data Folder. ... .
Access Data Folder as Normal..

How do I choose where to Download files on Android?

Click the menu icon in the upper-left corner and choose Settings. Scroll down to the Downloads section. Tap Default download location, and change the location or select a folder.

How do I save a Download to a specific folder?

You can choose a location on your computer where downloads should be saved by default or pick a specific destination for each download..
On your computer, open Chrome..
At the top right, click More. Settings..
At the bottom, click Advanced. Downloads..
Adjust your download settings:.