title: DownloadManager not working for Android 10 (Q)
body: <p>I've been beating my head against this issue for quite awhile... I am updating an app that uses DownloadManger to do a simple task like downloading a file to the external storage public directory i.e:</p>
  
  <pre><code>Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
  </code></pre>
  
  <p>Everything works fine here from Android api 19-28. Its when testing on API 29 (Q/10) is where issues occur. Android implemented scoped storage and so deprecated the getExternalStoragePublicDirectory... As a result I need to figure out a compatible solution to support APIs 19-<strong>29</strong>. I cannot use internal application storage since DownloadManager will throw a SecurityException. Androids documentation states that I can use the DownloadManager.Request <code>setDestinationUri</code> and it even mentions for Android Q that I can use <code>Context.getExternalFilesDir(String)</code>. When I do this though, the path is still the emulated path:</p>
  
  <pre><code>/storage/emulated/0/Android/data/com.my.package.name/files/Download/myFile.xml
  </code></pre>
  
  <p>I get a callback from the download manager that the download is complete (with right ID) but then I cannot grab the download from the area I saved it to. I check to see if the file exists and it returns false:</p>
  
  <pre><code>new File("/storage/emulated/0/Android/data/com.my.package.name/files/Download/myFile.xml").exists();
  </code></pre>
  
  <p>Any help is appreciated</p>
  
  <p>Adding code for context. So setting up download manager</p>
  
  <pre><code>    private void startDownload() {
          IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
          registerReceiver(downloadReceiver, filter);
  
          String remoteURL= getString(R.string.remote_url);
  
          DownloadManager.Request request = new DownloadManager.Request(Uri.parse(remoteUrl));
          request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
          request.setTitle(getString(R.string.download_title));
          request.setDescription(getString(R.string.download_description));
          request.setDestinationUri(Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "myFile.xml")));
  
          DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
          mainDownloadID= manager.enqueue(request);
      }
  </code></pre>
  
  <p>checking file if it exists:</p>
  
  <pre><code>new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "myFile.xml").exists(); //this returns false in the onReceive (and download IDs match)
  </code></pre>