title: How to make DatePickerDialog maintaining selected user date when changing screen orientation?
body: <p><b>In an opened DatePickerDialog, when screen orientation is changed, it reset the selected user data.</b><br/></p>
  
  <p><em>(the DatePickerDialog does NOT CLOSE and it does not maintain the selected data)</em></p>
  
  <p>Code:</p>
  
  <pre><code>public class ActivityNeki extends FragmentActivity {
      DialogFragment newDF = null;
      private int datY, datM, datD;
  
      @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
          setContentView(R.layout.activity);
          if(savedInstanceState == null){ setTheData(); writeTheData(); }
      }
  
      @Override protected void onSaveInstanceState(Bundle outState) {
          outState.putInt("izY", datY); outState.putInt("izM", datM); outState.putInt("izD", datD);
          super.onSaveInstanceState(outState);
      }
      @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState);
          datY = savedInstanceState.getInt("izY"); datM = savedInstanceState.getInt("izM"); datD = savedInstanceState.getInt("izD");
          writeTheData();
      }
  
      public void onClickOpenDPD(View view) {    // the method that is caled from XML onClick
          class MyDialogFragment extends DialogFragment {
              @Override public void onDestroyView() {
                  if (getDialog() != null &amp;&amp; getRetainInstance()) getDialog().setDismissMessage(null);
                  super.onDestroyView();
              }
              @Override public void onCreate(Bundle state) { super.onCreate(state);
                  setRetainInstance(true);
              }
              @Override public Dialog onCreateDialog(Bundle state) {
                  DatePickerDialog dpd = new DatePickerDialog( getActivity(), new DatePickerDialog.OnDateSetListener() {
                      @Override public void onDateSet(DatePicker view, int leto, int mesec, int dan) {
                          datY = leto; datM = mesec; datD = dan;
                          writeTheData();
                  } }, datY, datM, datD);
                  return dpd;
              }
          }
          newDF = new MyDialogFragment();
          newDF.show( getSupportFragmentManager(), null );
      }
      public void setTheData(){
          Calendar c = Calendar.getInstance();
          datY = c.get(Calendar.YEAR); datM = c.get(Calendar.MONTH); datD = c.get(Calendar.DAY_OF_MONTH);
      }
      public void writeTheData(){  /* writes the data in a txtView */ }
  }
  </code></pre>
  
  <p>suggestion me, how to solve this issue?</p>