# DownloadManager.Request

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Constants](https://developer.android.com/reference/android/app/DownloadManager.Request#constants)\|[Ctors](https://developer.android.com/reference/android/app/DownloadManager.Request#pubctors)\|[Methods](https://developer.android.com/reference/android/app/DownloadManager.Request#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/app/DownloadManager.Request#inhmethods)  

# DownloadManager.Request

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/DownloadManager.Request "View this page in Kotlin")\|Java

`
public
static


class
DownloadManager.Request
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.DownloadManager.Request |

<br />

*** ** * ** ***

This class contains all the information necessary to request a new download. The URI is the only required parameter. Note that the default download destination is a shared volume where the system might delete your file if it needs to reclaim space for system use. If this is a problem, use a location on external storage (see[setDestinationUri(android.net.Uri)](https://developer.android.com/reference/android/app/DownloadManager.Request#setDestinationUri(android.net.Uri)).

## Summary

|                                                                                                                                                                                                 ### Constants                                                                                                                                                                                                 ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [NETWORK_MOBILE](https://developer.android.com/reference/android/app/DownloadManager.Request#NETWORK_MOBILE) Bit flag for[setAllowedNetworkTypes(int)](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedNetworkTypes(int))corresponding to[ConnectivityManager.TYPE_MOBILE](https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_MOBILE). |
| `int` | [NETWORK_WIFI](https://developer.android.com/reference/android/app/DownloadManager.Request#NETWORK_WIFI) Bit flag for[setAllowedNetworkTypes(int)](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedNetworkTypes(int))corresponding to[ConnectivityManager.TYPE_WIFI](https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_WIFI).         |
| `int` | [VISIBILITY_HIDDEN](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_HIDDEN) This download doesn't show in the UI or in the notifications.                                                                                                                                                                                                                       |
| `int` | [VISIBILITY_VISIBLE](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_VISIBLE) This download is visible but only shows in the notifications while it's in progress.                                                                                                                                                                                              |
| `int` | [VISIBILITY_VISIBLE_NOTIFY_COMPLETED](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_VISIBLE_NOTIFY_COMPLETED) This download is visible and shows in the notifications while in progress and after completion.                                                                                                                                                 |
| `int` | [VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION) This download shows in the notifications after completion ONLY.                                                                                                                                                                     |

|                                                                                    ### Public constructors                                                                                     ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Request](https://developer.android.com/reference/android/app/DownloadManager.Request#Request(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` uri) ` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|-----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[addRequestHeader](https://developer.android.com/reference/android/app/DownloadManager.Request#addRequestHeader(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` header, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Add an HTTP header to be included with the download request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                   | ` `[allowScanningByMediaScanner](https://developer.android.com/reference/android/app/DownloadManager.Request#allowScanningByMediaScanner())`() ` *This method was deprecated in API level 29. Starting in Q, this value is ignored. Files downloaded to directories owned by applications (e.g.[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String))) will not be scanned by MediaScanner and the rest will be scanned.*                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setAllowedNetworkTypes](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedNetworkTypes(int))`(int flags) ` Restrict the types of networks over which this download may proceed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setAllowedOverMetered](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedOverMetered(boolean))`(boolean allow) ` Set whether this download may proceed over a metered network connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setAllowedOverRoaming](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedOverRoaming(boolean))`(boolean allowed) ` Set whether this download may proceed over a roaming connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setDescription](https://developer.android.com/reference/android/app/DownloadManager.Request#setDescription(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` description) ` Set a description of this download, to be displayed in notifications (if enabled)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setDestinationInExternalFilesDir](https://developer.android.com/reference/android/app/DownloadManager.Request#setDestinationInExternalFilesDir(android.content.Context,%20java.lang.String,%20java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, `[String](https://developer.android.com/reference/java/lang/String)` dirType, `[String](https://developer.android.com/reference/java/lang/String)` subPath) ` Set the local destination for the downloaded file to a path within the application's external files directory (as returned by[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)).                                                                                                                                                                                                                                  |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setDestinationInExternalPublicDir](https://developer.android.com/reference/android/app/DownloadManager.Request#setDestinationInExternalPublicDir(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` dirType, `[String](https://developer.android.com/reference/java/lang/String)` subPath) ` Set the local destination for the downloaded file to a path within the public external storage directory (as returned by[Environment.getExternalStoragePublicDirectory(String)](https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String))).                                                                                                                                                                                                                                                                                                                      |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setDestinationUri](https://developer.android.com/reference/android/app/DownloadManager.Request#setDestinationUri(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` uri) ` Set the local destination for the downloaded file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setMimeType](https://developer.android.com/reference/android/app/DownloadManager.Request#setMimeType(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` mimeType) ` Set the MIME content type of this download.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setNotificationVisibility](https://developer.android.com/reference/android/app/DownloadManager.Request#setNotificationVisibility(int))`(int visibility) ` Control whether a system notification is posted by the download manager while this download is running or when it is completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setRequiresCharging](https://developer.android.com/reference/android/app/DownloadManager.Request#setRequiresCharging(boolean))`(boolean requiresCharging) ` Specify that to run this download, the device needs to be plugged in.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setRequiresDeviceIdle](https://developer.android.com/reference/android/app/DownloadManager.Request#setRequiresDeviceIdle(boolean))`(boolean requiresDeviceIdle) ` Specify that to run, the download needs the device to be in idle mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setShowRunningNotification](https://developer.android.com/reference/android/app/DownloadManager.Request#setShowRunningNotification(boolean))`(boolean show) ` *This method was deprecated in API level 15. use[setNotificationVisibility(int)](https://developer.android.com/reference/android/app/DownloadManager.Request#setNotificationVisibility(int))*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setTitle](https://developer.android.com/reference/android/app/DownloadManager.Request#setTitle(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` title) ` Set the title of this download, to be displayed in notifications (if enabled).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` `[DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | ` `[setVisibleInDownloadsUi](https://developer.android.com/reference/android/app/DownloadManager.Request#setVisibleInDownloadsUi(boolean))`(boolean isVisible) ` *This method was deprecated in API level 29. Starting in Q, this value is ignored. Only files downloaded to public Downloads directory (as returned by[Environment.getExternalStoragePublicDirectory(String)](https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String))with[Environment.DIRECTORY_DOWNLOADS](https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOWNLOADS)) will be visible in system's Downloads UI and the rest will not be visible. All non-visible downloads that are not modified in the last 7 days will be deleted during idle runs. (e.g.[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String))) will not be visible.* |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Constants

### NETWORK_MOBILE

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int NETWORK_MOBILE
```

Bit flag for[setAllowedNetworkTypes(int)](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedNetworkTypes(int))corresponding to[ConnectivityManager.TYPE_MOBILE](https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_MOBILE).

<br />

Constant Value: 1 (0x00000001)  

### NETWORK_WIFI

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int NETWORK_WIFI
```

Bit flag for[setAllowedNetworkTypes(int)](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedNetworkTypes(int))corresponding to[ConnectivityManager.TYPE_WIFI](https://developer.android.com/reference/android/net/ConnectivityManager#TYPE_WIFI).

<br />

Constant Value: 2 (0x00000002)  

### VISIBILITY_HIDDEN

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VISIBILITY_HIDDEN
```

This download doesn't show in the UI or in the notifications.

<br />

Constant Value: 2 (0x00000002)  

### VISIBILITY_VISIBLE

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VISIBILITY_VISIBLE
```

This download is visible but only shows in the notifications while it's in progress.

<br />

Constant Value: 0 (0x00000000)  

### VISIBILITY_VISIBLE_NOTIFY_COMPLETED

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED
```

This download is visible and shows in the notifications while in progress and after completion.

<br />

Constant Value: 1 (0x00000001)  

### VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION
```

This download shows in the notifications after completion ONLY. It is usuable only with[DownloadManager.addCompletedDownload(String, String,
boolean, String, String, long, boolean)](https://developer.android.com/reference/android/app/DownloadManager#addCompletedDownload(java.lang.String,%20java.lang.String,%20boolean,%20java.lang.String,%20java.lang.String,%20long,%20boolean)).

<br />

Constant Value: 3 (0x00000003)

## Public constructors

### Request

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Request (Uri uri)
```

<br />

<br />

|                       Parameters                        ||
|-------|--------------------------------------------------|
| `uri` | `Uri`: the HTTP or HTTPS URI to download. <br /> |

## Public methods

### addRequestHeader

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request addRequestHeader (String header, 
                String value)
```

Add an HTTP header to be included with the download request. The header will be added to the end of the list.

<br />

|                 Parameters                  ||
|----------|-----------------------------------|
| `header` | `String`: HTTP header name <br /> |
| `value`  | `String`: header value <br />     |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

**See also:**

- [HTTP/1.1 Message Headers](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2)  

### allowScanningByMediaScanner

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void allowScanningByMediaScanner ()
```

<br />

**This method was deprecated in API level 29.**   
Starting in Q, this value is ignored. Files downloaded to directories owned by applications (e.g.[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String))) will not be scanned by MediaScanner and the rest will be scanned.

If the file to be downloaded is to be scanned by MediaScanner, this method should be called before[DownloadManager.enqueue(Request)](https://developer.android.com/reference/android/app/DownloadManager#enqueue(android.app.DownloadManager.Request))is called.

<br />

### setAllowedNetworkTypes

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setAllowedNetworkTypes (int flags)
```

Restrict the types of networks over which this download may proceed. By default, all network types are allowed. Consider using[setAllowedOverMetered(boolean)](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedOverMetered(boolean))instead, since it's more flexible.

As of[Build.VERSION_CODES.N](https://developer.android.com/reference/android/os/Build.VERSION_CODES#N), setting only the[NETWORK_WIFI](https://developer.android.com/reference/android/app/DownloadManager.Request#NETWORK_WIFI)flag here is equivalent to calling[setAllowedOverMetered(boolean)](https://developer.android.com/reference/android/app/DownloadManager.Request#setAllowedOverMetered(boolean))with`false`.

<br />

|                             Parameters                              ||
|---------|------------------------------------------------------------|
| `flags` | `int`: any combination of the NETWORK_\* bit flags. <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setAllowedOverMetered

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setAllowedOverMetered (boolean allow)
```

Set whether this download may proceed over a metered network connection. By default, metered networks are allowed.

<br />

|        Parameters         ||
|---------|------------------|
| `allow` | `boolean` <br /> |

|                                                    Returns                                                     ||
|--------------------------------------------------------------------------------------------------------|--------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | <br /> |

**See also:**

- [ConnectivityManager.isActiveNetworkMetered()](https://developer.android.com/reference/android/net/ConnectivityManager#isActiveNetworkMetered())  

### setAllowedOverRoaming

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setAllowedOverRoaming (boolean allowed)
```

Set whether this download may proceed over a roaming connection. By default, roaming is allowed.

<br />

|                                  Parameters                                   ||
|-----------|--------------------------------------------------------------------|
| `allowed` | `boolean`: whether to allow a roaming connection to be used <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setDescription

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setDescription (CharSequence description)
```

Set a description of this download, to be displayed in notifications (if enabled)

<br />

|              Parameters              ||
|---------------|-----------------------|
| `description` | `CharSequence` <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setDestinationInExternalFilesDir

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setDestinationInExternalFilesDir (Context context, 
                String dirType, 
                String subPath)
```

Set the local destination for the downloaded file to a path within the application's external files directory (as returned by[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)).

The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling[allowScanningByMediaScanner()](https://developer.android.com/reference/android/app/DownloadManager.Request#allowScanningByMediaScanner()).

<br />

|                                                                                              Parameters                                                                                               ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context` | `Context`: the[Context](https://developer.android.com/reference/android/content/Context)to use in determining the external files directory <br />                                          |
| `dirType` | `String`: the directory type to pass to[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)) <br /> |
| `subPath` | `String`: the path within the external directory, including the destination filename <br />                                                                                                |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

|                                                                             Throws                                                                              ||
|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | If the external storage directory cannot be found or created. |

### setDestinationInExternalPublicDir

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setDestinationInExternalPublicDir (String dirType, 
                String subPath)
```

Set the local destination for the downloaded file to a path within the public external storage directory (as returned by[Environment.getExternalStoragePublicDirectory(String)](https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String))).

The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling[allowScanningByMediaScanner()](https://developer.android.com/reference/android/app/DownloadManager.Request#allowScanningByMediaScanner()).

For applications targeting[Build.VERSION_CODES.Q](https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q)or above,[WRITE_EXTERNAL_STORAGE](https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE)permission is not needed and the`dirType`must be one of the known public directories like[Environment.DIRECTORY_DOWNLOADS](https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOWNLOADS),[Environment.DIRECTORY_PICTURES](https://developer.android.com/reference/android/os/Environment#DIRECTORY_PICTURES),[Environment.DIRECTORY_MOVIES](https://developer.android.com/reference/android/os/Environment#DIRECTORY_MOVIES), etc.

<br />

|                                                                                                              Parameters                                                                                                              ||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dirType` | `String`: the directory type to pass to[Environment.getExternalStoragePublicDirectory(String)](https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String)) <br /> |
| `subPath` | `String`: the path within the external directory, including the destination filename <br />                                                                                                                               |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

|                                                                             Throws                                                                              ||
|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | If the external storage directory cannot be found or created. |

### setDestinationUri

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setDestinationUri (Uri uri)
```

Set the local destination for the downloaded file. Must be a file URI to a path on external storage, and the calling application must have the WRITE_EXTERNAL_STORAGE permission.

The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling[allowScanningByMediaScanner()](https://developer.android.com/reference/android/app/DownloadManager.Request#allowScanningByMediaScanner()).

By default, downloads are saved to a generated filename in the shared download cache and may be deleted by the system at any time to reclaim space.

For applications targeting[Build.VERSION_CODES.Q](https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q)or above,[WRITE EXTERNAL_STORAGE](https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE)permission is not needed and the`uri`must refer to a path within the directories owned by the application (e.g.[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String))) or a path within the top-level Downloads directory (as returned by[Environment.getExternalStoragePublicDirectory(String)](https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String))with[Environment.DIRECTORY_DOWNLOADS](https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOWNLOADS)). All non-visible downloads that are not modified in the last 7 days will be deleted during idle runs.

<br />

|                                                                  Parameters                                                                  ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------|
| `uri` | `Uri`: a file[Uri](https://developer.android.com/reference/android/net/Uri)indicating the destination for the downloaded file. <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setMimeType

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setMimeType (String mimeType)
```

Set the MIME content type of this download. This will override the content type declared in the server's response.

<br />

|         Parameters          ||
|------------|-----------------|
| `mimeType` | `String` <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

**See also:**

- [HTTP/1.1 Media Types](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7)  

### setNotificationVisibility

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setNotificationVisibility (int visibility)
```

Control whether a system notification is posted by the download manager while this download is running or when it is completed. If enabled, the download manager posts notifications about downloads through the system[NotificationManager](https://developer.android.com/reference/android/app/NotificationManager). By default, a notification is shown only when the download is in progress.

It can take the following values:[VISIBILITY_HIDDEN](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_HIDDEN),[VISIBILITY_VISIBLE](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_VISIBLE),[VISIBILITY_VISIBLE_NOTIFY_COMPLETED](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_VISIBLE_NOTIFY_COMPLETED).

If set to[VISIBILITY_HIDDEN](https://developer.android.com/reference/android/app/DownloadManager.Request#VISIBILITY_HIDDEN), this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.

<br />

|                        Parameters                        ||
|--------------|--------------------------------------------|
| `visibility` | `int`: the visibility setting value <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setRequiresCharging

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setRequiresCharging (boolean requiresCharging)
```

Specify that to run this download, the device needs to be plugged in. This defaults to false.

<br />

|                                   Parameters                                   ||
|--------------------|------------------------------------------------------------|
| `requiresCharging` | `boolean`: Whether or not the device is plugged in. <br /> |

|                                                    Returns                                                     ||
|--------------------------------------------------------------------------------------------------------|--------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | <br /> |

**See also:**

- [JobInfo.Builder.setRequiresCharging(boolean)](https://developer.android.com/reference/android/app/job/JobInfo.Builder#setRequiresCharging(boolean))  

### setRequiresDeviceIdle

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setRequiresDeviceIdle (boolean requiresDeviceIdle)
```

Specify that to run, the download needs the device to be in idle mode. This defaults to false.

Idle mode is a loose definition provided by the system, which means that the device is not in use, and has not been in use for some time.

<br />

|                                                  Parameters                                                  ||
|----------------------|----------------------------------------------------------------------------------------|
| `requiresDeviceIdle` | `boolean`: Whether or not the device need be within an idle maintenance window. <br /> |

|                                                    Returns                                                     ||
|--------------------------------------------------------------------------------------------------------|--------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | <br /> |

**See also:**

- [JobInfo.Builder.setRequiresDeviceIdle(boolean)](https://developer.android.com/reference/android/app/job/JobInfo.Builder#setRequiresDeviceIdle(boolean))  

### setShowRunningNotification

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setShowRunningNotification (boolean show)
```

<br />

**This method was deprecated in API level 15.**   
use[setNotificationVisibility(int)](https://developer.android.com/reference/android/app/DownloadManager.Request#setNotificationVisibility(int))

Control whether a system notification is posted by the download manager while this download is running. If enabled, the download manager posts notifications about downloads through the system[NotificationManager](https://developer.android.com/reference/android/app/NotificationManager). By default, a notification is shown. If set to false, this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.

<br />

|                                              Parameters                                              ||
|--------|----------------------------------------------------------------------------------------------|
| `show` | `boolean`: whether the download manager should show a notification for this download. <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setTitle

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setTitle (CharSequence title)
```

Set the title of this download, to be displayed in notifications (if enabled). If no title is given, a default one will be assigned based on the download filename, once the download starts.

<br />

|           Parameters           ||
|---------|-----------------------|
| `title` | `CharSequence` <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |

### setVisibleInDownloadsUi

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DownloadManager.Request setVisibleInDownloadsUi (boolean isVisible)
```

<br />

**This method was deprecated in API level 29.**   
Starting in Q, this value is ignored. Only files downloaded to public Downloads directory (as returned by[Environment.getExternalStoragePublicDirectory(String)](https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String))with[Environment.DIRECTORY_DOWNLOADS](https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOWNLOADS)) will be visible in system's Downloads UI and the rest will not be visible. All non-visible downloads that are not modified in the last 7 days will be deleted during idle runs. (e.g.[Context.getExternalFilesDir(String)](https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String))) will not be visible.

Set whether this download should be displayed in the system's Downloads UI. True by default.

<br />

|                                     Parameters                                      ||
|-------------|------------------------------------------------------------------------|
| `isVisible` | `boolean`: whether to display this download in the Downloads UI <br /> |

|                                                          Returns                                                           ||
|--------------------------------------------------------------------------------------------------------|--------------------|
| [DownloadManager.Request](https://developer.android.com/reference/android/app/DownloadManager.Request) | this object <br /> |