Skip to content

Commit

Permalink
Show "NOT FOUND" if ID (key) does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
oluiscabral committed Dec 13, 2024
1 parent b2b330b commit 2d22945
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ class StorageDemoFragment : DialogFragment() {

btnGetId.setOnClickListener {
val id = binding.edtGetId.text.toString()
storage?.get(id)?.let { value ->
Toast.makeText(requireContext(), value, Toast.LENGTH_SHORT).show()
}
val value = storage?.get(id)
Toast.makeText(
requireContext(),
if (value?.isNotBlank() == true) value else "NOT FOUND",
Toast.LENGTH_SHORT
).show()
}
}

Expand Down

0 comments on commit 2d22945

Please sign in to comment.