title: How to get Real path from Uri in android 11
body: <p>How to get Real path from URI in android 10 and android 11. Getting the Uri from intent data i.e.</p>
  <pre><code> private val startForResult =
          registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult -&gt;
              if (result.resultCode == Activity.RESULT_OK) {
                  val uri = result.data?.data
                
              }
          }
  </code></pre>
  <p>and intent to get pdf file</p>
  <pre><code> val mimeType = &quot;application/pdf&quot;
              val intent = Intent(Intent.ACTION_GET_CONTENT)
              intent.type = mimeType
              intent.addCategory(Intent.CATEGORY_OPENABLE)
   if (packageManager.resolveActivity(sIntent, 0) != null) {
              // it is device with Samsung file manager
              chooserIntent = Intent.createChooser(sIntent, &quot;Select an PDF File&quot;)
              chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arrayOf(intent))
          } else {
              chooserIntent = Intent.createChooser(intent, &quot;Select an PDF File&quot;)
          }
          try {
              chooserIntent.resolveActivity(packageManager)?.let {
                  //  startActivityForResult(Intent.createChooser(this,&quot;Pick MHT file&quot;),1)
                  startForResult.launch(chooserIntent)
              }
          } catch (ex: ActivityNotFoundException) {
              Toast.makeText(
                  applicationContext,
                  &quot;No suitable File Manager was found.&quot;,
                  Toast.LENGTH_SHORT
              ).show()
          }
  </code></pre>