title: Android SavedInstanceState - how to save variable from different type of method
body: <p>I am implementing a simple app (tennis score), and I want to save the set variables before they can be destroyed by the methods when rotating the screen:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  int scorePlayerOne = 0;    // Tracks the score for Player One
  int scorePlayerTwo = 0;    // Tracks the score for Player Two
  int set1PlayerOne = 0;     // Track the score set for Player One
  int set2PlayerOne = 0;
  int set3PlayerOne = 0;
  int set1PlayerTwo = 0;     // Track the score set for Player Two
  int set2PlayerTwo = 0;
  int set3PlayerTwo = 0;
  int setOfTheGame = 1;      // Tracks the current set of the game
  
  // Declaring and initializing KEY_INDEX to serve as NVP (Name-Value Pair).
  private static final String KEY_INDEX = "index";
  private static final String KEY_INDEX2 = "index2";
  
   @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      if (savedInstanceState != null) {
          scorePlayerOne = savedInstanceState.getInt(KEY_INDEX, scorePlayerOne);
      }
      if (savedInstanceState != null) {
          scorePlayerTwo = savedInstanceState.getInt(KEY_INDEX2, scorePlayerTwo);
      }
      setContentView(R.layout.activity_main);
      displayForPlayerOne(scorePlayerOne);
      displayForPlayerTwo(scorePlayerTwo);
  }
  
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
      super.onSaveInstanceState(savedInstanceState);
        /*
      *Save UI state changes to the savedInstanceState.
      * This bundle will be passed to onCreate if the process is
      * killed and restarted.
      * Storing a NVP ("Name-Value Pair") map, and it will get
      * passed in to onCreate () method.
      */
      savedInstanceState.putInt(KEY_INDEX, scorePlayerOne);
      savedInstanceState.putInt(KEY_INDEX2, scorePlayerTwo);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>What I want to do next is to be able to save the remaining (set's variables), I can't do this because the set's variables have the different type of methods (View) and i can't call them onCreate(Bundle savedInstanceState) method </p>
  
  <p>example:</p>
  
  <pre><code> /**
   * Increase the score of the set for Player One by 1 point.
   */
  public void addSetScoreForPlayerOne(View v) {
  
      if (setOfTheGame == 1) {
          if ((set1PlayerOne == 6 &amp;&amp; set1PlayerOne - set1PlayerTwo &gt;= 2)
                  || (set1PlayerOne == 7)) {
              setOfTheGame = 2;
              set2PlayerOne++;
              TextView scoreView = findViewById(R.id.player_one_score_set_2);
              scoreView.setText(String.valueOf(set2PlayerOne));
          } else {
              set1PlayerOne++;
          }
  </code></pre>
  
  <p>Is there a way to figure out this kind of problem?
  Thx!</p>