Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions dfc/src/main/java/com/lazygeniouz/dfc/resolver/ResolverCompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,20 @@ internal object ResolverCompat {
* Get [Cursor] from [ContentResolver.query] with given [projection] on a given [uri].
*/
fun getCursor(context: Context, uri: Uri, projection: Array<String>): Cursor? {
return context.contentResolver.query(
uri, projection, null, null, null
)
return try {
context.contentResolver.query(
uri, projection, null, null, null
)
} catch (exception: Exception) {
/**
* This exception can occur in scenarios such as -
*
* - The Uri became invalid due to external changes (e.g., permissions revoked, storage unmounted, etc).
* - The file or directory represented by this Uri was probably deleted or became `inaccessible` after the Uri was obtained but before this operation was performed.
*/
ErrorLogger.logError("Exception while building the Cursor", exception)
null
}
}

// Make children uri for query.
Expand Down