I have a Mainactivity which contains a Layout which is parent of 4 sub layout. on clicking on sub layout i am going to a new fragment replacing main layout. But i cant go ba
You can Override the onBackPressed of MainActivity
@Override public void onBackPressed() { if (getFragmentManager().getBackStackEntryCount() > 1) { getFragmentManager().popBackStack(); } else { super.onBackPressed(); } }