1

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.

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

1 Answers1

0

This is because two different mechanisms are used. I think this link can help.

Community
  • 1
  • 1
no id
  • 1,642
  • 3
  • 24
  • 36