diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 0ba186d14..9f24504b3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -847,14 +847,14 @@ fun Context.getFavoritePaths(): ArrayList { fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath()) fun Context.updateFavorite(path: String, isFavorite: Boolean) { - if (isFavorite) { - try { + try { + if (isFavorite) { favoritesDB.insert(getFavoriteFromPath(path)) - } catch (e: Exception) { - toast(R.string.unknown_error_occurred) + } else { + favoritesDB.deleteFavoritePath(path) } - } else { - favoritesDB.deleteFavoritePath(path) + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) } }