title: Android: Default preference value not being set from XML
body: <p>I have a simple Preferences Activity that I populate via XML, defining the values as array resources.</p>
  
  <p>In the MAIN Activity of the application, I get a handle to this via:</p>
  
  <pre><code>mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
  </code></pre>
  
  <p>In the XML for the only preference I have, which is a display setting, I have the following XML that defines the ListPreference:</p>
  
  <pre><code>&lt;ListPreference
          android:title="@string/pref_title_sort"
          android:summary="@string/pref_summary_sort"
          android:key="@string/pref_key_sort"
          android:defaultValue="modified"
          android:entries="@array/sort_order"
          android:entryValues="@array/sort_order_values" /&gt;
  </code></pre>
  
  <p>You can see I am trying to set the default value to 'modified', which is a value found in @array/sort_order_values:</p>
  
  <pre><code>&lt;string-array name="sort_order_values"&gt;
      &lt;item&gt;modified&lt;/item&gt;
      &lt;item&gt;created&lt;/item&gt;
      &lt;item&gt;name&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p>However, when the Preferences Activity is launched, none of the items are selected by default.</p>
  
  <p>I've tried adding the following line to my Activity, but it did not change anything (where pref_main is the XML file that defines the preferences):</p>
  
  <pre><code>PreferenceManager.setDefaultValues(this, R.xml.pref_main, false);
  </code></pre>
  
  <p>Any help appreciated!</p>
  
  <p>Paul</p>