How to set a button permanently enabled?
<p>I want to know on how to set a button enabled permanently so that every time I exit the app, it still be on enabled state. In my application there are 2 activities. Activity1 has a 2 buttons. When you click the first button you will intent to Activity 2 which has a button. when you click that button on activity 2 you will go back to Activity 1 and then the 2nd button on activity1 will be setEnabled.</p>

<p>I've tried this one but every time it enables a button its not setting it permanently.</p>

<p>first I create AppPreferences class</p>

<pre><code>public class AppPreferences {
      private static final String APP_SHARED_PREFS = "com.aydabtu.BroadcastSMS_preferences"; //  Name of the file -.xml
         private SharedPreferences appSharedPrefs;
         private Editor prefsEditor;

         public AppPreferences(Context context)
         {
             this.appSharedPrefs = context.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
             this.prefsEditor = appSharedPrefs.edit();
         }

         public boolean getOnOrOff() {
             return appSharedPrefs.getBoolean("get_on_or_off", false);

         }

         public void setOnOrOFF(Boolean text) {
             prefsEditor.putBoolean("get_on_or_off", text);
             prefsEditor.commit();
         }
}
</code></pre>

<p>then on my button I've set this code</p>

<pre><code>AppPreferences appPrefs = new AppPreferences(getApplicationContext());
    Button page2 = (Button) findViewById(R.id.button2);

    Intent intent2=getIntent();
    String isEnabled2 = intent2.getStringExtra("isEnabled2");
    if(isEnabled2==null||isEnabled2.equals("disabled")){
            page2.setEnabled(false);
    }
    else{
            page2.setEnabled(appPrefs.getOnOrOff());
            appPrefs.setOnOrOFF(true);
    }

    page2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

            Intent myIntent = new Intent(view.getContext(), p3.class);
            startActivityForResult(myIntent, 0);

        }
    });
</code></pre>
