mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-31 04:06:43 +01:00
crashfix at getRealPathFromURI
This commit is contained in:
parent
02f855a30d
commit
c524044d11
1 changed files with 5 additions and 3 deletions
|
@ -10,9 +10,11 @@ fun Context.getRealPathFromURI(uri: Uri): String? {
|
||||||
try {
|
try {
|
||||||
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
||||||
cursor = contentResolver.query(uri, projection, null, null, null)
|
cursor = contentResolver.query(uri, projection, null, null, null)
|
||||||
val index = cursor!!.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
cursor.moveToFirst()
|
val index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
|
||||||
return cursor.getString(index)
|
return cursor.getString(index)
|
||||||
|
}
|
||||||
|
return null
|
||||||
} finally {
|
} finally {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue