Pepa Zapletal
Pepa Zapletal

Reputation: 2979

Android - Download manager issue with Uri from StorageAccessFramework as destination

I'm using in my app DownloadManager for downloading the files. I'm using this method:

Request.setDestinationUri()

and if I set as the destination Uri of the file from External storage it works OK. But if I set as the destination Uri from the SAF:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, REQUEST_CODE_FOR_DESTINATION);

Uri treeUri = data.getData();
DocumentFile destinationDirUri = DocumentFile.fromTreeUri(this, treeUri);

//I create new file on SD card and I use Uri from this new file

But I get this exception

java.lang.IllegalArgumentException: Not a file URI: content://com.android.externalstorage.documents/tree/D224-A5C1%3Abadu%2Fsd/document/D224-A5C1%3Abadu%2Fsd%2Ff6%2F27%2F85%2Ff4f8d950-d0b7-11e5-9c3c-4b49c28527f6

Can DownloadManager downloads files to the SD card? Do you know how to solve this problem?

Upvotes: 1

Views: 2560

Answers (1)

Pepa Zapletal
Pepa Zapletal

Reputation: 2979

It's not possible. Because of Must be a file URI to a path on external storage...

https://developer.android.com/reference/android/app/DownloadManager.Request.html#setDestinationUri(android.net.Uri)

Upvotes: 4

Related Questions