title: Android: why am I not able to open pdf downloaded from DownloadManager inside public Download/myfolder directory in Android 11?
body: <p>I wasn't facing this issue in Android 9 and in Android 10 i opted out for Legacy Storage. But in Android 11, I am not able to open the file downloaded from Download Manager. The same file can be opened from file Manager, though.</p>
  <p>Also, I checked the owner of that file, it is showing com.android.providers.downloads and not my app.</p>
  <p>I am also creating a pdf file in Document/myfolder directory, and it can be easily openable using intent and there my app is the owner of that file.</p>
  <p>Also, if I am saving the downloaded file to Document/myfolder directory, it still can't be opened using that intent.</p>
  <p>As per my understanding, from Android 11, they introduced scope storage, and if the owner of that file is  accessing it. It will allow to read/write through READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permission.</p>
  <p>For both the file, I am using the same Intent.</p>
  <p>Anyone has idea how to change the owner of my downloaded file so that i can gain open or what is the exact reason i am not able to open that downloaded file?</p>
  <pre><code> Intent intent = new Intent(Intent.ACTION_VIEW);
  
   intent.setDataAndType(uri, PDF_TYPE);
  
   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
  
   intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  </code></pre>
  <p>Here PDF_TYPE is correct and uri is also correct.</p>
  <p>DownloadManager code is also correct here a small snippet</p>
  <pre><code>                        .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, subPath.getPath());
  </code></pre>