catch exceptions thrown at getting mimetype from uri

This commit is contained in:
tibbi 2017-10-29 10:29:57 +01:00
parent 70afd655ae
commit de1c418f78

View file

@ -82,7 +82,10 @@ fun Context.getSortedDirectories(source: ArrayList<Directory>): ArrayList<Direct
fun Context.getMimeTypeFromUri(uri: Uri): String {
var mimetype = uri.path.getMimeTypeFromPath()
if (mimetype.isEmpty()) {
try {
mimetype = contentResolver.getType(uri)
} catch (e: IllegalStateException) {
}
}
return mimetype
}