I create two xml files, one in activity_main other is activity_main_land. Both have 2 EditText fields. Both have ids and in both XML ids are same. When onConfigchange() method is called I change XML file. Now when I rotate device EditText lost the data. Can you Please help me to get rid this problem.
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Toast.makeText(MainActivity.this, "simple", Toast.LENGTH_SHORT).show();
    if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
        Toast.makeText(MainActivity.this, "Landscape", Toast.LENGTH_SHORT).show();
        setContentView(R.layout.activity_main_land);
    }else if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(MainActivity.this, "portreate", Toast.LENGTH_SHORT).show();
        setContentView(R.layout.activity_main);
    }
I also tried reference of:
 
     
    