title: How to check if the fragment exists
body: <p>I am trying to talk to the fragments from activity.</p>
  
  <p>Here in my MainActivity I am adding multiple fragments ok so for fine.</p>
  
  <p>My main requirement is I don't want to add if fragment is already added.</p>
  
  <p>So how can we check this condition?</p>
  
  <p>Please help me some one.</p>
  
  <h2>code:-</h2>
  
  <pre><code> private void intializingFragments(Fragment fragment) {
  
          FragmentManager fragmentManager = getSupportFragmentManager();
  
          FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
          fragmentTransaction.add(R.id.fragment_container, fragment);
          fragmentTransaction.addToBackStack(null);
          fragmentTransaction.commit();
      }
  
      private View.OnClickListener intialization() {
  
          return new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  int getId = v.getId();
  
                  if (getId == R.id.first) {
                      intializingFragments(new Fragment1());
  
                  } else if (getId == R.id.second) {
                      intializingFragments(new Fragment2());
  
                  } else if (getId == R.id.third) {
                      intializingFragments(new Fragment3());
                  } 
              }
          };
      }
  </code></pre>