Which is the correct way to read a string preference with a default value?
- prefs.getString("username", "Guest")
- prefs.read("username")
- prefs.username
- prefs.getString("username")
Answer
A) prefs.getString("username", "Guest")
The second parameter is returned if the key is missing.
Computer Science MCQ · More UI Events, Views, Preferences and Data Storage MCQs · Practise