mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-24 15:30:57 +01:00
handle cases when column _data does not exist
This commit is contained in:
parent
3d089db697
commit
c7dd7b7e2e
@ -13,14 +13,15 @@ fun Context.getRealPathFromURI(uri: Uri): String? {
|
||||
try {
|
||||
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
||||
cursor = contentResolver.query(uri, projection, null, null, null)
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
if (cursor?.moveToFirst() == true) {
|
||||
val index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
|
||||
return cursor.getString(index)
|
||||
}
|
||||
return null
|
||||
} catch (e: IllegalArgumentException) {
|
||||
} finally {
|
||||
cursor?.close()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun Context.getHumanizedFilename(path: String): String {
|
||||
|
Loading…
Reference in New Issue
Block a user