fragmentTransaction.replace(int containerViewId, Fragment fragment, String tag)
Description It replaces the existing fragment added to the container. This is essentially the same as calling remove(Fragment) for all the fragments currently added that were added with the same container, and then add(int, Fragment, String) with the same arguments given here.
fragmentTransaction.add(int containerViewId, Fragment fragment, String tag)
Description It adds a fragment to the state of activity. This fragment may also have its own form (if Fragment.onCreateView returns nonzero) in the activity container view.
Please visit the official Android developer link below for more information on snippets ... http://developer.android.com/guide/components/fragments.html
Priyank Patel
source share