Im trying to download file from my android
Unity3D
app with java
plugin and DownloadManager
system service.
When I try to download to internal memory everything works fine. The same piece of code works fine with sd card formatted as internal storage.
But when I try to set absolute destination path to my sd-card (folder of my application) - I get ERROR_FILE_ERROR.
For example I got path like /storage/45A9-E58B/Android/data/com.Company.ProductName/files
I can create and change files inside this directory from Unity3D
application. But I can not download files to this path via DownloadManager
.
I got WRITE_EXTERNAL_STORAGE
in manifest and has also requested memory permission in runtime (and I can read\write files inside my app just fine). But DownloadManager
won't download to this path.
my java call looks like:
File f = new File(destUri);
Uri dest = Uri.fromFile(f);
request = new DownloadManager.Request(url);
request.setDestinationUri(dest);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
manager = (DownloadManager)context.getSystemService(Context.DOWNLOAD_SERVICE);
id = manager.enqueue(request);
I also tried .setDestinationInExternalFilesDir()
and Environment.getExternalStorageDirectory()
but both on them return internal storage path.
Any advice please? (Galaxy Tab A, Android 9 -if it helps)