You can add, remove, replace or perform actions with fragments in your activity in response to user interaction. A transaction is a set of changes you perform to an activity and these can be performed using APIs in FragmentTransaction. These transaction can be saved on back stack and allow the user to navigate these changes.
To get an instance from FragmentManager, following code is used.
Java Code: This is the code to create a fragment
FragmentManager fragmentManager = getFragmentManager()