title: Button is always set to disabled
body: <p>What I want to do is disable those buttons If <code>Boolean</code> num10, num11 and so on are set to <code>true</code>. But when I open the <code>SecondActivity</code>, it always shows disabled buttons. Even If I didn't pressed the button. </p>
  
  <p>What should I do?</p>
  
  <p>This is my code:</p>
  
  <pre><code>import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.preference.PreferenceManager;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class SecondActivity extends AppCompatActivity {
  
      Button buyItem1,buyItem2,buyItem3,buyItem4;
      SharedPreferences mySharedPreferences2;
      boolean num10 = false, num11 = false, num12 = false, num13 = false;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          mySharedPreferences2 = PreferenceManager.getDefaultSharedPreferences(this);
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_second);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          Intent intent = getIntent();
          final int goldamountval = intent.getIntExtra("parameter1", 0);
          TextView goldamount = (TextView) findViewById(R.id.goldamount);
          goldamount.setText("" + goldamountval);
          buyItem1 = (Button) findViewById(R.id.buyitem1);
          buyItem2 = (Button) findViewById(R.id.buyitem2);
          buyItem3 = (Button) findViewById(R.id.buyitem3);
          buyItem4 = (Button) findViewById(R.id.buyitem4);
          buyItem1.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  if(goldamountval &gt;= 1000){
                      SharedPreferences.Editor editor = mySharedPreferences2.edit();
                      editor.putBoolean(String.valueOf(num10), true);
                      editor.apply();
                  }
              }
          });
  
          buyItem2.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  if(goldamountval &gt;= 5000){
                      SharedPreferences.Editor editor = mySharedPreferences2.edit();
                      editor.putBoolean(String.valueOf(num11), true);
                      editor.apply();
                  }
              }
          });
  
          buyItem3.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  if(goldamountval &gt;= 10000){
                      SharedPreferences.Editor editor = mySharedPreferences2.edit();
                      editor.putBoolean(String.valueOf(num12), true);
                      editor.apply();
                  }
              }
          });
  
          buyItem4.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  if(goldamountval &gt;= 50000){
                      SharedPreferences.Editor editor = mySharedPreferences2.edit();
                      editor.putBoolean(String.valueOf(num13), true);
                      editor.apply();
                  }
              }
          });
          if (num10 = true){
              buyItem1.setEnabled(false);
              Button button = (Button)findViewById(R.id.item4);
              button.setText("Drill");
          }
          if (num11 = true){
              buyItem2.setEnabled(false);
              Button button = (Button)findViewById(R.id.item5);
              button.setText("Excavator");
          }
          if (num12 = true){
              buyItem3.setEnabled(false);
              Button button = (Button)findViewById(R.id.item6);
              button.setText("Digger");
          }
          if (num13 = true){
              buyItem4.setEnabled(false);
              Button button = (Button)findViewById(R.id.item7);
              button.setText("Mine Permission");
          }
      }
  }
  </code></pre>