Set default value for GUI PreferenceActivity during runtime
<p>I have the following XML.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;PreferenceCategory
        android:title="@string/preference_xxx_category"&gt;
        &lt;CheckBoxPreference
            android:title="@string/preference_xxx_dual_mode_title"
            android:summary="@string/preference_xxx_dual_mode_summary"
            android:key="xxxDualModePreference" /&gt;
    &lt;/PreferenceCategory&gt;    
&lt;/PreferenceScreen&gt;
</code></pre>

<p>I use a GUI to load it as the following code</p>

<pre><code>public class Preferences extends SherlockPreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.preferences);

        this.getPreferenceManager().findPreference("xxxDualModePreference").setDefaultValue(Utils.isDualCoreDevice());
        this.getPreferenceManager().findPreference("xxxDualModePreference").setEnabled(Utils.isDualCoreDevice());

        // Once the GUI is shown, I realize my preference UI check box is not being ticked.
</code></pre>

<p><strong>The default value should depend on the number of device CPU core. That's why I cannot specific the default value in XML.</strong></p>

<p>However, if I specific the default value in Java code, I realize the UI is not reflecting it, although this is the first time I start my application.</p>

<p>Is there any other steps I had missed out?</p>

<p>Thanks.</p>
