Are the values in android app preferences saved automatically?
<p>I am trying to create preferences for an experimental app for android. However I can get the preferences to work. </p>

<p>The preference that I want to use determine the display langue and use this function to retrieve it:</p>

<pre><code>private String selectLang()
{
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String lang = preferences.getString("lang", "n/a");
    return lang;
}
</code></pre>

<p>Then inside onCreate method for the ListActivity I use this code to display the right language:</p>

<pre><code>String lang =  selectLang();
String title = (lang == "english") ? "English" : "Arabic";
</code></pre>

<p>title is a column in the database. The code does not seem to work and I get Arabic no matter what. I used this code just to know the value of lang:</p>

<pre><code>Toast.makeText(this, lang, Toast.LENGTH_LONG).show();
</code></pre>

<p>and I get "english" but the English language does not display.</p>

<p>Here is is my XML for the list:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
&lt;string-array name="lang"&gt;
    &lt;item&gt;Arabic&lt;/item&gt;
    &lt;item&gt;English&lt;/item&gt;
&lt;/string-array&gt;
&lt;string-array name="langValues"&gt;
    &lt;item&gt;arabic&lt;/item&gt;
    &lt;item&gt;english&lt;/item&gt;
&lt;/string-array&gt;
&lt;/resources&gt;
</code></pre>

<p>I have read in number of answers here on SO that I should use SharedPreference editor but I could not get a full working example of that.</p>

<p>Can you please help?</p>
