Reputation: 21
In CheckBoxPreference, what is the difference between "android:defaultValue" and "android:checked"? Both seems to be doing the same thing
<CheckBoxPreference
android:key="pref_"
android:title=""
android:summary=""
android:defaultValue="true"
android:checked="true">
</CheckBoxPreference>
Upvotes: -1
Views: 175
Reputation: 389
@andychen the default value tag defines what value should be fetched from preference if the user hasn't explicitly stored any value for checkbox in preference. And tag checked defines what state of checkbox should be shown to user on screen initialization
Upvotes: 0
Reputation: 731
Sets the checked state and saves it to the SharedPreferences. And Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.
Upvotes: 0