catch exceptions thrown at getting file date taken
This commit is contained in:
parent
db210e8bd1
commit
0a98fd0536
|
@ -894,17 +894,15 @@ fun Context.getFileDateTaken(path: String): Long {
|
||||||
val selection = "${Images.Media.DATA} = ?"
|
val selection = "${Images.Media.DATA} = ?"
|
||||||
val selectionArgs = arrayOf(path)
|
val selectionArgs = arrayOf(path)
|
||||||
|
|
||||||
|
try {
|
||||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||||
cursor?.use {
|
cursor?.use {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
|
||||||
try {
|
|
||||||
return cursor.getLongValue(Images.Media.DATE_TAKEN)
|
return cursor.getLongValue(Images.Media.DATE_TAKEN)
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0L
|
return 0L
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue