code: public void clear() {
          if (fm != null) {
              fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
          }
          fm = null;
      }
docs: Clears fragment manager backstack and the fragment manager itself.