- // Get the OpenKeychain version name if it is installed. If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is an empty string.
- val openKeychain: String = requireContext().packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0)?.versionName ?: ""
+ // Get the OpenKeychain version name if it is installed.
+ val openKeychain: String = try {
+ // If the safe call (`?.`) is null, the Elvis operator (`?"`) returns the following value instead, which is an empty string.
+ requireContext().packageManager.getPackageInfo("org.sufficientlysecure.keychain", 0).versionName ?: ""
+ } catch (exception: PackageManager.NameNotFoundException) {
+ // Store an empty string.
+ ""
+ }