title: Passing data between two fragments
body: <p>Let's say I'd like to pass data from Fragment A to Fragment B but it throws a nullpointerexception at Fragment B. I'd like to pass the data without use of activity. How do I resolve this?</p>
  
  <p>In FragmentA.java </p>
  
  <pre><code>FragmentB ldf = new FragmentB ();
  Bundle args = new Bundle();
  args.putString("gender", genderSelected);
  args.putString("name", name.getText().toString());
  args.putString("contact", contactNo.getText().toString());
  args.putString("age", age.getText().toString());
  ldf.setArguments(args);
  
  //Inflate the fragment
  getFragmentManager().beginTransaction().add(R.id.fragmentContainer,ldf).commit();
  </code></pre>
  
  <p>In FragmentB.java - in onCreateView() method</p>
  
  <p>//Receive data from previous fragment - to be submitted in save</p>
  
  <pre><code> String age = getArguments().getString("age");
   String gender = getArguments().getString("gender");
   String contact = getArguments().getString("contact");
   String name = getArguments().getString("name");
  </code></pre>