diff --git a/commons/src/main/kotlin/org/fossify/commons/extensions/Context.kt b/commons/src/main/kotlin/org/fossify/commons/extensions/Context.kt index 1cd124ad1b..eeefcef54a 100644 --- a/commons/src/main/kotlin/org/fossify/commons/extensions/Context.kt +++ b/commons/src/main/kotlin/org/fossify/commons/extensions/Context.kt @@ -811,7 +811,12 @@ fun Context.storeNewYourAlarmSound(resultData: Intent): AlarmSound { baseConfig.yourAlarmSounds = Gson().toJson(yourAlarmSounds) val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION - contentResolver.takePersistableUriPermission(uri, takeFlags) + try { + contentResolver.takePersistableUriPermission(uri, takeFlags) + } catch (_: SecurityException) { + // some file managers return a content uri without a persistable + // permission grant, which would otherwise crash the app + } return newAlarmSound }