To save when you rotate the screen using the method

public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); //outState.putInt("count", cnt); Log.d("myLog", "onSaveInstanceState"); } 

And how can I save the view element? more specifically, EditText

    2 answers 2

    You can save information about the element and only, because when you rotate the screen, all life-cycle methods work again.

    However, if you place your EditText in a fragment, set the setOnRetainInstance(true); flag in the body of the onCreateView() method setOnRetainInstance(true); - then at screen rotation only view will be destroyed, but the data will remain. In other words, for a time, the fragment is detached, retaining all of its internal state, and then recreated according to the current parameters.

    I think how the alternative might work.

      For saving the contents specifically in the EditText widget when the screen is rotated, the methods of the base class are responsible and additional efforts to save it (except for calling super.* For life-cycle methods) are not required from the programmer