This is the function responsible for adding fragments to back stack:
public void populateContent(File f)
{
ContentFragment cf = new ContentFragment(ctx, ac,
It seems that calling addToBackStack() on fragment transaction is not enough, we have to handle the popping up of the back stack upon Back button pressed by ourselves. I added this to my activity and it worked as expected:
@Override
public void onBackPressed() {
if (getFragmentManager().getBackStackEntryCount() > 0 ){
getFragmentManager().popBackStack();
} else {
super.onBackPressed();
}
}