title: setting application language from shared preferences
body: <p>i just finished my first android application, 
  but i still have a little problem to fix:
  i made my app over two languages; if my phone is set up to run in french the app is being displayed in french and if the phone is set up to English it's running in English
  The issue is that i made a shared preference value, to let the user of the app, choosing his preferred language manually , unfortunately that's not working.</p>
  
  <p>this is my shared preference:</p>
  
  <pre><code> &lt;ListPreference
          android:defaultValue="English"
          android:entries="@array/Languages"
          android:entryValues="@array/LanguagesValues"
          android:key="language"
          android:summary="@string/Define_the_default_language"
          android:title="@string/Language" /&gt;
  </code></pre>
  
  <p>and this is how i tried to implement that:</p>
  
  <pre><code>SharedPreferences pref = PreferenceManager
              .getDefaultSharedPreferences(this);
      lan = pref.getString("language", null);
      Log.e("langues", lan);
  
      SharedPreferences prefs = this.getSharedPreferences("language", 0);
      listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
  
          public void onSharedPreferenceChanged(SharedPreferences prefs,
                  String key) {
              prefs.registerOnSharedPreferenceChangeListener(listener);
              if (lan.equals("FRENSH")) {
                  setLocale("FRENSH");
                  System.out.println("frensh");
  </code></pre>
  
  <p>the SetLocal activity:</p>
  
  <pre><code>    public void setLocale(String lang) {
      myLocale = new Locale(lang);
      Resources res = getResources();
      DisplayMetrics dm = res.getDisplayMetrics();
      Configuration conf = res.getConfiguration();
      conf.locale = myLocale;
      Log.e("", "" + myLocale);
      res.updateConfiguration(conf, dm);
      Intent refresh = new Intent(this, Setting.class);
      startActivity(refresh);
  }
  </code></pre>
  
  <p>How can I fix it?</p>