title: How to save locale in Android?
body: <p>I need to save the locale of an app whenever user selects one from spinner. Right now i's able to change it, but it need to save the session if user exits the app.</p>
  
  <p>heres my code:</p>
  
  <pre><code>  Locale locale = new Locale(lang);
      Locale.setDefault(locale);
      Configuration config = new Configuration();
      config.locale = locale;
      getActivity().getBaseContext().getResources().updateConfiguration(config,
              getActivity().getBaseContext().getResources().getDisplayMetrics());
  
   SharedPreferences shp = getActivity().getSharedPreferences(
              "android.exaple.com.PREFERENCES", Context.MODE_PRIVATE);
      SharedPreferences.Editor editor = shp.edit();
      editor.putString("USER_LANGUAGE", lang);
      editor.apply();
  </code></pre>