ListPreference default value not showing up

index = listPreference.findIndexOfValue(listPreference.value)

I found that sometime I need to clear application data. Uninstall and reinstall the app. After that, everything works as expected.

I found that I have to call PreferenceManager.setDefaultValues() in my Preferences Activity in order for my default value to show up initially.

public class PreferencesActivity extends PreferenceActivity {

    protected void onCreate (Bundle savedInstanceState) {

        // This static call will reset default values only on the first ever read
        PreferenceManager.setDefaultValues(getBaseContext(), R.xml.settings, false);