title: How to get actual path of image from Uri in Android Q?
body: <p>I'm taking picture using camera and selecting from gallery. After that doing compression to reduce file size. I was using <code>getRealPathFromURI()</code> method to get actual image path, but in Android Q<code>MediaStore.Images.Media.DATA</code> is deprecated.</p>
  
  <pre><code>fun getRealPathFromURI(contentUri: Uri, activityContext: Activity): String {
      val proj = arrayOf(MediaStore.Images.Media.DATA)
      val cursor = activityContext.managedQuery(contentUri, proj, null, null, null)
      val column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
      cursor.moveToFirst()
      return cursor.getString(column_index)
  }
  </code></pre>
  
  <p>As per documentation I tried <code>openFileDescriptor()</code> to gain access:</p>
  
  <pre><code>private fun getBitmapFromUri(context: Context, uri: Uri): Bitmap {
      val parcelFileDescriptor = context.contentResolver.openFileDescriptor(uri, "rw")
      val fileDescriptor = parcelFileDescriptor?.fileDescriptor
      val image = BitmapFactory.decodeFileDescriptor(fileDescriptor)
      parcelFileDescriptor?.close()
      return image
  }
  </code></pre>
  
  <p>also tried <a href="https://stackoverflow.com/a/52095352">this</a></p>