I am in the following situation: I want to get the path of an Uri and this solution works fine.
fun getPath(context: Context, uri: Uri): String {
var result: String? = null
val proj = arrayOf(MediaStore.Images.Media.DATA)
val cursor = context.contentResolver.query(uri, proj, null, null, null)
if (cursor != null) {
if (cursor.moveToFirst()) {
val column_index = cursor.getColumnIndexOrThrow(proj[0])
result = cursor.getString(column_index)
}
cursor.close()
}
if (result == null) {
result = "Not found"
}
return result
}
Problem: MediaStore.Images.Media.DATA
is deprecated and I do not know what I should I use instead.
Thanks for helping.