mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-24 13:08:33 +00:00
Added try/catch to prevent cursor index out of bound exception
This commit is contained in:
parent
8cda9a028a
commit
fd826926db
1 changed files with 7 additions and 2 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
package org.linphone.utils
|
package org.linphone.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.database.CursorIndexOutOfBoundsException
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.OpenableColumns
|
import android.provider.OpenableColumns
|
||||||
|
|
@ -158,9 +159,13 @@ class FileUtils {
|
||||||
returnCursor.moveToFirst()
|
returnCursor.moveToFirst()
|
||||||
val nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
val nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
||||||
if (nameIndex != -1) {
|
if (nameIndex != -1) {
|
||||||
name = returnCursor.getString(nameIndex)
|
try {
|
||||||
|
name = returnCursor.getString(nameIndex)
|
||||||
|
} catch (e: CursorIndexOutOfBoundsException) {
|
||||||
|
Log.e("[File Utils] Failed to get the display name for URI $uri, exception is $e")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("[File Utils] Couldn't get DISPLAY_NAME column index for URI $uri")
|
Log.e("[File Utils] Couldn't get DISPLAY_NAME column index for URI: $uri")
|
||||||
}
|
}
|
||||||
returnCursor.close()
|
returnCursor.close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue