title: how to call method of one fragment from another fragment class in android
body: <p>I want to call a method of FragmentB (Class) from a fragmentA I tried by making a object of fragmentb in fragmentA (class) but it's not working
  here is the code of fragmentA in this class I have a method through which I will call the method of FragmentB class</p>
  
  <pre><code>adddata.setOnClickListener(
          new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              boolean isInserted = myDb.addalldata(monthly_income.getText().toString(),
                  room_rent.getText().toString(),
                  mess_rent.getText().toString());
              if (isInserted = true)
                  Toast.makeText(getActivity().getBaseContext(), "Data Inserted", Toast.LENGTH_LONG).show();
              else
              Toast.makeText(getActivity().getBaseContext(), "Data not Inserted", Toast.LENGTH_LONG).show();
          }
      }
  );
  </code></pre>
  
  <p>I want to call this method of fragmentB</p>
  
  <pre><code>public void show() {
      Cursor res = myDb.getAllData();
      StringBuffer buffer = new StringBuffer();
      while (res.moveToNext()) {
          displayresult.setText( buffer.append( res.getString(1)));
      }
  }
  </code></pre>
  
  <p>I tried by writing this code in method of fragmentA but am getting error</p>
  
  <pre><code>FragmentA fragment=          
      (FragmentA)getSupportFragmentManager().findFragmentById(R.id.pageview2);
      ((FragmentA)fragment).show();
  </code></pre>