title: Android: how to prevent data to be saved after rotation
body: <p>I want to prevent a creation of a note object when the screen is rotated.
  I know that a new activity is created after rotation, framework will save all the editable widgets data before destroying that activity.</p>
  
  <p>I have a cancel button that works fine when I don't rotate the screen.
  The outer else activiated when I rotate the screen.  </p>
  
  <pre><code>   @Override
  protected void onPause() {
      super.onPause();
      if (mIsCancelling) {
          if (mIsNewNote) {
              Log.d(TRACE_TAG, "onPause() : mIsCancelling == true &amp;&amp; mIsNewNote == true =&gt; DataManager.removeNote(position:" + mNotePosition + ")");
              DataManager.getInstance().removeNote(mNotePosition);
          }
          else {
              Log.d(TRACE_TAG, "onPause() : mIsCancelling == true &amp;&amp; mIsNewNote == false =&gt; storePreviousNoteValues()");
              storePreviousNoteValues();
          }
      } else {
          Log.d(TRACE_TAG, "onPause() : mIsCancelling == false =&gt; saveNote()");
          saveNote();
      }
  }
  
     @Override
  protected void onSaveInstanceState(Bundle outState) {
      Log.d(TRACE_TAG, "onSaveInstanceState(outState)");
      super.onSaveInstanceState(outState);
      outState.putString(ORIGINAL_NOTE_COURSE_ID, mOriginalNoteCourseId);
      outState.putString(ORIGINAL_NOTE_TITLE, mOriginalNoteTitle);
      outState.putString(ORIGINAL_NOTE_TEXT, mOriginalNoteText);
  }
  
  private void restoreOriginalNoteValues(Bundle savedInstanceState) {
      Log.d(TRACE_TAG, "restoreOriginalNoteValues(savedInstanceState)");
      mOriginalNoteCourseId = savedInstanceState.getString(ORIGINAL_NOTE_COURSE_ID);
      mOriginalNoteTitle = savedInstanceState.getString(ORIGINAL_NOTE_TITLE);
      mOriginalNoteText = savedInstanceState.getString(ORIGINAL_NOTE_TEXT);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_note);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      mSpinnerCourses = (Spinner) findViewById(R.id.spinner_courses);
  
      List&lt;CourseInfo&gt; courses = DataManager.getInstance().getCourses();
      ArrayAdapter&lt;CourseInfo&gt; adapterCourses =
              new ArrayAdapter&lt;&gt;(this, android.R.layout.simple_spinner_item, courses);
      adapterCourses.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mSpinnerCourses.setAdapter(adapterCourses);
  
      Log.d(TRACE_TAG, "OnCreate(savedInstanceState) =&gt; readDisplayStateValues()");
      readDisplayStateValues();
      if (savedInstanceState == null) {
          Log.d(TRACE_TAG, "OnCreate(savedInstanceState) : savedInstanceState == null =&gt; saveOriginalNoteValues()");
          saveOriginalNoteValues();
      }
      else {
          Log.d(TRACE_TAG, "OnCreate(savedInstanceState) : savedInstanceState != null =&gt; restoreOriginalNoteValues(savedInstanceState)");
          restoreOriginalNoteValues(savedInstanceState);
      }
  
      mTextNoteTitle = (EditText) findViewById(R.id.text_note_title);
      mTextNoteText = (EditText) findViewById(R.id.text_note_text);
  
      if (!mIsNewNote) {
          Log.d(TRACE_TAG, "OnCreate(savedInstanceState) : mIsNewNote == false =&gt; displayNote(...)");
          displayNote(mSpinnerCourses, mTextNoteTitle, mTextNoteText);
      }
  }
  </code></pre>