public static class

DownloadManager.Request

extends Object
java.lang.Object
   ↳ android.app.DownloadManager.Request

Class Overview

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(Uri).

Summary

Constants
int NETWORK_MOBILE Bit flag for setAllowedNetworkTypes(int) corresponding to TYPE_MOBILE.
int NETWORK_WIFI Bit flag for setAllowedNetworkTypes(int) corresponding to TYPE_WIFI.
Public Constructors
DownloadManager.Request(Uri uri)
Public Methods
DownloadManager.Request addRequestHeader(String header, String value)
Add an HTTP header to be included with the download request.
DownloadManager.Request setAllowedNetworkTypes(int flags)
Restrict the types of networks over which this download may proceed.
DownloadManager.Request setAllowedOverRoaming(boolean allowed)
Set whether this download may proceed over a roaming connection.
DownloadManager.Request setDescription(CharSequence description)
Set a description of this download, to be displayed in notifications (if enabled)
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 getExternalFilesDir(String).
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 getExternalStoragePublicDirectory(String).
DownloadManager.Request setDestinationUri(Uri uri)
Set the local destination for the downloaded file.
DownloadManager.Request setMimeType(String mimeType)
Set the MIME content type of this download.
DownloadManager.Request setShowRunningNotification(boolean show)
Control whether a system notification is posted by the download manager while this download is running.
DownloadManager.Request setTitle(CharSequence title)
Set the title of this download, to be displayed in notifications (if enabled).
DownloadManager.Request setVisibleInDownloadsUi(boolean isVisible)
Set whether this download should be displayed in the system's Downloads UI.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int NETWORK_MOBILE

Since: API Level 9

Bit flag for setAllowedNetworkTypes(int) corresponding to TYPE_MOBILE.

Constant Value: 1 (0x00000001)

public static final int NETWORK_WIFI

Since: API Level 9

Bit flag for setAllowedNetworkTypes(int) corresponding to TYPE_WIFI.

Constant Value: 2 (0x00000002)

Public Constructors

public DownloadManager.Request (Uri uri)

Since: API Level 9

Parameters
uri the HTTP URI to download.

Public Methods

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

Since: API Level 9

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

Parameters
header HTTP header name
value header value
Returns
  • this object

public DownloadManager.Request setAllowedNetworkTypes (int flags)

Since: API Level 9

Restrict the types of networks over which this download may proceed. By default, all network types are allowed.

Parameters
flags any combination of the NETWORK_* bit flags.
Returns
  • this object

public DownloadManager.Request setAllowedOverRoaming (boolean allowed)

Since: API Level 9

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

Parameters
allowed whether to allow a roaming connection to be used
Returns
  • this object

public DownloadManager.Request setDescription (CharSequence description)

Since: API Level 9

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

Returns
  • this object

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

Since: API Level 9

Set the local destination for the downloaded file to a path within the application's external files directory (as returned by getExternalFilesDir(String).

Parameters
context the Context to use in determining the external files directory
dirType the directory type to pass to getExternalFilesDir(String)
subPath the path within the external directory, including the destination filename
Returns
  • this object

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

Since: API Level 9

Set the local destination for the downloaded file to a path within the public external storage directory (as returned by getExternalStoragePublicDirectory(String).

Parameters
dirType the directory type to pass to getExternalStoragePublicDirectory(String)
subPath the path within the external directory, including the destination filename
Returns
  • this object

public DownloadManager.Request setDestinationUri (Uri uri)

Since: API Level 9

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. 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.

Returns
  • this object

public DownloadManager.Request setMimeType (String mimeType)

Since: API Level 9

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

Returns
  • this object

public DownloadManager.Request setShowRunningNotification (boolean show)

Since: API Level 9

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. By default, a notification is shown. If set to false, this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.

Parameters
show whether the download manager should show a notification for this download.
Returns
  • this object

public DownloadManager.Request setTitle (CharSequence title)

Since: API Level 9

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.

Returns
  • this object

public DownloadManager.Request setVisibleInDownloadsUi (boolean isVisible)

Since: API Level 9

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

Parameters
isVisible whether to display this download in the Downloads UI
Returns
  • this object