title: Android App Change language functionality code bug
body: <p>I am creating an app which have functionality for user to <strong>choose different language</strong> so i created another app to test fuctionality there so idea is to create button in settings and save its <strong>Language Value</strong> and <strong>onclick</strong> the language changes and saving its value using shared preference there is <strong>no error</strong> in my code but the <strong>language is not changing</strong>. I am unable to figure please guys <strong>any help is appreciated.</strong> <strong>HERE IS CODE FIRST MAIN THEN SETTINGS</strong>:</p>
  
  <pre><code>TextView text;
      int language;
      SharedPreferences sh;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          text=(TextView)findViewById(R.id.text);
          sh=getSharedPreferences("lang", Context.MODE_PRIVATE);
          language=sh.getInt("language",0);
          Button Lang=(Button)findViewById(R.id.change);
          if(language==0)
          {
              text.setText("Germany");
          }
          else
          if(language==1)
          {
              text.setText("English");
          }
          Lang.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i=new Intent(MainActivity.this,gauravmehra.testastro.Change.class);
                  startActivity(i);
              }
          });
      }
  </code></pre>
  
  <p>And <strong>change Activity</strong></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.change);
          changeLang=(Button)findViewById(R.id.changeLang);
          sh=getSharedPreferences("lang",Context.MODE_PRIVATE);
          language=sh.getInt("language",0);
          changeLang.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if(language==0)
                  {
                      language=1;
                      sh.edit().putInt("language",1);
                      sh.edit().commit();
                  }
                  else if(language==1)
                  {
                      language=0;
                      sh.edit().putInt("language",0);
                      sh.edit().commit();
                  }
                  Intent i=new Intent(Change.this,MainActivity.class);
                  startActivity(i);
              }
          });
      }
  </code></pre>