I had created a frame layout at my Main Activity and added fragment 1 into the layout when the app launch.
Fragment fr;
fr = new fragment1();
FragmentManager fm = getFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.fragment_place, fr);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
After this when the user presses something on Fragment 1, it will start fragment 2.
Fragment2 newFragment = new Fragment2();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_place, newFragment);
transaction.addToBackStack(null);
transaction.commit();
The problem now is when I press back button on fragment 2, it will back to fragment 1 but reload fragment 1. And when I press back button again, it will back to fragment 2 again. Anyone can help me on this question as I only want fragment 1 to be saved at all the time and fragment 2 is destroy when the user presses the back button.