Multiple choice

Which data type can be stored using shared preferences?

  1. Any data type

  2. Primitive data type

  3. Advance data type

  4. Option (2) and (3)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

SharedPreferences in Android stores key-value pairs where values must be primitive data types: boolean, float, int, long, and String (or Set). Complex objects like custom classes cannot be directly stored - they must be serialized to primitives first.