title: How to open Pdf in android 11 from scoped storage
body: <p>I have a question about file permissions in <strong>android 11</strong>. I am trying to open a PDF file in PDF viewer from my application but I am unable to do that because of the change in permissions in android 11. Can someone please give me a code snippet of how to do that since I am unable to find any code regarding this issue.</p>
  <p>I am saving the pdf file in
  <code>context.getApplicationInfo().dataDir</code></p>
  <p>I have tried to open the pdf file via</p>
  <pre><code>        val pdfFile = File(filePath)
          pdfIntent.setDataAndType(Uri.fromFile(pdfFile), &quot;application/pdf&quot;)
          pdfIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_HISTORY
  
          pdfIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
          pdfIntent.flags = Intent.FLAG_ACTIVITY_NO_HISTORY
          context.startActivity(pdfIntent)
  </code></pre>
  <p>this code is running on devices below android 11 but not working on android 11.</p>
  <pre><code>        val pdfIntent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { 
                           addCategory(Intent.CATEGORY_OPENABLE) 
                          }
          val pdfFile = File(filePath)
          pdfIntent.setDataAndType(Uri.fromFile(pdfFile), &quot;application/pdf&quot;)
          pdfIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_HISTORY
  
          pdfIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
          pdfIntent.flags = Intent.FLAG_ACTIVITY_NO_HISTORY
          context.startActivity(pdfIntent)
  </code></pre>
  <p>I found this code in searching of scope storage but nothing happened</p>