title: Keep variables after leaving activity
body: <p>I am trying to find a way to keep my variables constant throughout the life of the app.  The way I have designed the app is that a user clicks on a class and submits a grade.  What i would like is for the app to store the grade after the activity has been closed.  When the user backs out of the screen and goes back in, he must reenter the grade he got.</p>
  
  <p>The code for my pages are as follows:</p>
  
  <p>Class Choice Activity</p>
  
  <pre><code>public class ClassCore extends Activity {
  
      TextView eng101, eng102, mat186, com173;
      TextView eng101scr, eng102scr, mat186scr, com173scr;
      LinearLayout eng101bg, eng102bg, mat186bg, com173bg;
      Button coreReturn;
      int ss;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.classcore);
  
          eng101bg = (LinearLayout)findViewById(R.id.eng101bg);
          eng102bg = (LinearLayout)findViewById(R.id.eng102bg);
          mat186bg = (LinearLayout)findViewById(R.id.mat186bg);
          com173bg = (LinearLayout)findViewById(R.id.com173bg);
  
          eng101 = (TextView)findViewById(R.id.eng101);
          eng102 = (TextView)findViewById(R.id.eng102);
          mat186 = (TextView)findViewById(R.id.mat186);
          com173 = (TextView)findViewById(R.id.com173);
  
          eng101scr = (TextView)findViewById(R.id.eng101CoreScr);
          eng102scr = (TextView)findViewById(R.id.eng102CoreScr);
          mat186scr = (TextView)findViewById(R.id.mat186CoreScr);
          com173scr = (TextView)findViewById(R.id.com173CoreScr);
  
          coreReturn = (Button)findViewById(R.id.btnCoreRtrn);
  
  
          eng101.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent i = new Intent(ClassCore.this, Eng101.class);
                  i.putExtra("grades", "eng101" );
                  startActivityForResult(i, 1);
              }
          });
      }
  
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          // TODO Auto-generated method stub
          super.onActivityResult(requestCode, resultCode, data);
          if(data.getExtras().containsKey("e101FinalScore")){
              eng101scr.setText(data.getStringExtra("e101FinalScore"));
              eng101bg.setBackgroundColor(Color.parseColor("#00FF00"));
          }}
  </code></pre>
  
  <p>English Activity</p>
  
  <pre><code>public class Eng101 extends Activity {
  
      Button btnSubmit;
      EditText userGrade;
      String strGrade;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.eng101);
  
          btnSubmit = (Button)findViewById(R.id.btnE101);
          userGrade = (EditText)findViewById(R.id.eng101Scr);
  
          btnSubmit.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  strGrade = userGrade.getText().toString();
                  Intent i = getIntent();
                  String msg = i.getStringExtra("grades");
                  if(msg.contentEquals("eng101")){
                      i.putExtra("e101FinalScore", strGrade);
                      setResult(RESULT_OK, i);
                      finish();
                  }               
              }
          });     
      }   
  }
  </code></pre>