exam questions

Exam Associate Android Developer All Questions

View all questions & answers for the Associate Android Developer exam

Exam Associate Android Developer topic 1 question 52 discussion

Actual exam question from Google's Associate Android Developer
Question #: 52
Topic #: 1
[All Associate Android Developer Questions]

SharedPreferences.Editor is an interface used for modifying values in a SharedPreferences object. To mark in the editor that a preference value should be removed, which will be done in the actual preferences once commit() or apply() is called, what method in SharedPreferences.Editor should we use?

  • A. delete(String key)
  • B. clear()
  • C. remove(String key)
  • D. removeAll()
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
clear() method marks in the editor to remove ALL values from the preferences. Once commit is called, the only remaining preferences will be any that you have defined in this editor.
And no delete and removeAll method exists in SharedPreferences.Editor

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...