I am downloading data from server using the DownloadManager class in android. Data are saves to the external memory. But I want to save them to the internal memory. I did my researches and what I've found is from this link. I tried the second solution of cyngus :
public static final String PROVIDER_NAME = "com.provider.Downloads";
public static final Uri CONTENT_URI = Uri.parse("content://"+ PROVIDER_NAME + "/downloads")
DownloadManager.Request req = new DownloadManager.Request(Uri.parse(LINK));
req.setDestinationUri(CONTENT_URI);
It didnt work, it gave me the error: java.lang.IllegalArgumentException: Not a file URI: content://com.provider.Downloads/downloads
. What I am doing wrong?
The doc for DownloadManager.Request
clearly mentions that the destination you set for any of the setDestination*
methods must be on external storage and that your app must have WRITE_EXTERNAL_STORAGE
permission:
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.
I don't see how it would be possible to provide path to internal storage here.