title: multi language change in android studio app
body: <p>i am working on a project that i need to have some settings that users can choose there language</p>
  <p>when I use the old version of material design librarys , it work well
  but if i want to change the dependencys to androidX (android V30)
  it not work</p>
  <p>it's mean that if i use</p>
  <pre><code>import android.support.v7.app.ActionBar;
  import android.support.v7.app.AppCompatActivity;
  </code></pre>
  <p>it work but if i use</p>
  <pre><code>import androidx.appcompat.app.ActionBar;
  import androidx.appcompat.app.AppCompatActivity;
  </code></pre>
  <p>it not work</p>
  <p>not work means (the app will be launch but not work well)</p>
  <p>my main Activity is</p>
  <pre><code>package com.faranesh.saman.multilanguage2020;
  
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.content.SharedPreferences;
  import android.content.res.Configuration;
  import android.support.v7.app.ActionBar;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  import java.util.Locale;
  
  public class MainActivity extends AppCompatActivity {
  
  
      Button btn;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          LoadLocale();
          setContentView(R.layout.activity_main);
  
          ActionBar actionBar=getSupportActionBar();
          actionBar.setTitle(getResources().getString(R.string.app_name));
  
  
          btn=(Button)findViewById(R.id.btn_chang_language);
          btn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  ChangeLanguageState();
              }
          });
  
      }
  
  
      public void ChangeLanguageState(){
  
  
          final String[] listItem=new String[]{&quot;English&quot;,&quot;فارسی&quot;};
  
          AlertDialog.Builder dialog=new AlertDialog.Builder(this);
  
          dialog.setTitle(&quot;Chosse one Language....&quot;);
          dialog.setSingleChoiceItems(listItem, -1, new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
  
  
                  if (which==0){
  
                      setLocale(&quot;en&quot;);
                      recreate();
                  }else if (which==1){
                      setLocale(&quot;fa&quot;);
                      recreate();
                  }
  
                  dialog.dismiss();
              }
          });
  
          AlertDialog builder=dialog.create();
          builder.show();
  
      }
  
      public  void setLocale(String lang){
  
          Locale locale=new Locale(lang);
          Locale.setDefault(locale);
          Configuration configuration=new Configuration();
          configuration.locale=locale;
          getBaseContext().getResources().updateConfiguration(configuration,getBaseContext().getResources().getDisplayMetrics());
          SharedPreferences.Editor editor=getSharedPreferences(&quot;settings&quot;,MODE_PRIVATE).edit();
          editor.putString(&quot;MY_LANG&quot;,lang);
          editor.apply();
  
  
      }
  
      public void LoadLocale(){
  
          SharedPreferences sharepref=getSharedPreferences(&quot;settings&quot;,Activity.MODE_PRIVATE);
                  String language=sharepref.getString(&quot;MY_LANG&quot;,&quot;&quot;);
          setLocale(language);
      }
  }
  </code></pre>