When i set the the default value for a preference in the xml attribute android:defaultValue
, why do I still have to define a default value in code when accessing a preference using for example sharedPrefs.getString("foo", DEFAULT_STRING)
? This seems redundant to me.
Asked
Active
Viewed 183 times
1

Herr von Wurst
- 2,571
- 5
- 32
- 53
-
Because it **Returns: the preference value if it exists, or defValue. Throws ClassCastException if there is a preference with this name that is not a String.** – user755 Sep 11 '13 at 10:34