title: Setting defaultValue for Preference programmatically
body: <p>I have an <code>EditTextPreference</code> that needs to hold a phone number.  I want to default this preference to the handset's phone number programmatically, so I can't use the XML attribute <code>android:defaultValue</code>.  How would I go about doing this?  Here's what I'm trying but the default value still shows as empty:</p>
  
  <pre><code>public class SettingsActivity extends PreferenceActivity
  {
      @Override
      protected void onPostCreate(Bundle savedInstanceState)
      {
          super.onPostCreate(savedInstanceState);
  
          addPreferencesFromResource(R.xml.pref_general);
          TelephonyManager tMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
          String number = tMgr.getLine1Number();
          ((EditTextPreference)findPreference("phone_number")).setDefaultValue(number);
      }
  </code></pre>