I'm using Android new photo picker and I'm trying to get the photo's real file location, but the photo picker gives me the following URI content://media/picker/0/com.android.providers.media.photopicker/media/1000000020
I've also tried the below to get the real file location with the following, but that also seems to give me an inaccurate location when I check the image in files.
@Composable
private fun getRealPathFromURI(contentUri: Uri): String {
val projection = arrayOf(MediaStore.Images.Media.DATA)
val context = LocalContext.current
val cursor = context.contentResolver.query(contentUri, projection, null, null, null)
val columnIndex = cursor?.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
cursor?.moveToFirst()
val filePath = cursor?.getString(columnIndex!!)
cursor?.close()
println("filepath $filePath")
return filePath!!
}
/sdcard/.transforms/synthetic/picker/0/com.android.providers.media.photopicker/media/1000000003.jpg
Is this not possible?