title: Maintaining state of fragment or elements even when navigating away from the fragment
body: <p>I have a counterdown timer for my match time in a game that is within my match fragment;</p>
  
  <pre><code>//Countdown clock button
      Button counterBtn = (Button) view.findViewById(R.id.matchCountDownBtn);
      counterBtn.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              updateDBMatches("played", 1);
              final Button counterBtn = (Button) getView().findViewById(R.id.matchCountDownBtn);
              new CountDownTimer(20000, 1000){
                  public void onTick(long millisUntilFinished){
                      stopWatch.setVisibility(View.VISIBLE);
                      counterBtn.setEnabled(false);
                      long l = millisUntilFinished / 1000;
                      int i = (int) l;
                      counterBtn.setText(secondsToString(i));
                  }
                  public  void onFinish(){
                      MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.airhornsoundeffect);
                      mp.start();
                      //Disable score buttons
                      Button homeFoulsBtnDisabled = (Button) getView().findViewById(R.id.btnHomeFouls);
                      Button awayFoulsBtnDisabled = (Button) getView().findViewById(R.id.btnAwayFouls);
                      homeFoulsBtnDisabled.setEnabled(false);
                      awayFoulsBtnDisabled.setEnabled(false);
                      Button counterBtn = (Button) getView().findViewById(R.id.matchCountDownBtn);
                      stopWatch.setVisibility(View.INVISIBLE);
                      counterBtn.setText("FULL TIME");
                      updateDBMatches("played", 2);
                  }
              }.start();
          }
      });
  </code></pre>
  
  <p>All works great, until someone navigates to another fragment and I get errors once the countdown has completed. So for example the MediaPlayer mp when it tries to play the sound throws a null exception.</p>
  
  <p>Is there a way to maintain state of a fragment even if the user navigates to another one?</p>
  
  <p>All help appreciated.</p>