title: Pass data from activity to dialogFragment in android
body: <p>This is the method that I send the data from activity to dialog fragment</p>
  
  <pre><code> MultipleColorFragment multipleColorFragment = new MultipleColorFragment();//Get Fragment Instance
    Bundle data = new Bundle();//Use bundle to pass data
    for(int i = 0;i&lt;product_data_two.getColor().size();i++) {
    data.putStringArrayList(i + "", product_data_two.getColor().get(i));
    Log.d(TAG + " send fragment data",data.toString());
                              }
     data.putInt("size", product_data_two.getColor().size());
      multipleColorFragment.setArguments(data);//Finally set argument bundle to fragment
  
     final FragmentManager fm=getFragmentManager();
      multipleColorFragment.show(fm,"Color Set");
  </code></pre>
  
  <p>This is the method that I get back the data.</p>
  
  <pre><code>RecyclerView rv;
  ArrayList&lt;ArrayList&lt;String&gt;&gt; getArgument;
  
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.multiple_color_fragment_layout, container);
  
      //RECYCER
      rv = (RecyclerView) rootView.findViewById(R.id.multiple_color_recyclerview);
      rv.setLayoutManager(new LinearLayoutManager(this.getActivity()));
      rv.setLayoutManager(new GridLayoutManager(getActivity(), 6));
      rv.setAdapter(new MultipleColorAdapter());
  
      int size = getArguments().getInt("size");
  
      Log.d( " size : " + size ,"");
  
      for (int i = 0; i &lt; size; i++)
          getArgument.add(getArguments().getStringArrayList(i + ""));
  
      this.getDialog().setTitle("Color Set");
  
      return rootView;
  }
  </code></pre>
  
  <p>I find that the data that I pass is right. However, I cannot get back the data in the fragment. Can anyoun help me to figure out the problem? Thank you very much.</p>
  
  <p>Update:</p>
  
  <p>ProductTypeTwo.java</p>
  
  <pre><code>public class ProductTypeTwo {
  
  private String productName;
  private String brandID;
  private String description;
  private String productImage;
  private Long colorNo;
  private String category;
  private String uid;
  private ArrayList&lt;ArrayList&lt;String&gt;&gt; color;
  
  public ProductTypeTwo(String productName, String brandID, String description, String productImage, Long colorNo, String category, String uid, ArrayList&lt;ArrayList&lt;String&gt;&gt; color) {
      this.productName = productName;
      this.brandID = brandID;
      this.description = description;
      this.productImage = productImage;
      this.colorNo = colorNo;
      this.category = category;
      this.uid = uid;
      this.color = color;
  }
  
  
  public ProductTypeTwo()
  {
  
  }
  
  public String getProductName() {
      return productName;
  }
  
  public void setProductName(String productName) {
      this.productName = productName;
  }
  
  public String getBrandID() {
      return brandID;
  }
  
  public void setBrandID(String brandID) {
      this.brandID = brandID;
  }
  
  public String getDescription() {
      return description;
  }
  
  public void setDescription(String description) {
      this.description = description;
  }
  
  public String getProductImage() {
      return productImage;
  }
  
  public void setProductImage(String productImage) {
      this.productImage = productImage;
  }
  
  public Long getColorNo() {
      return colorNo;
  }
  
  public void setColorNo(Long colorNo) {
      this.colorNo = colorNo;
  }
  
  public String getCategory() {
      return category;
  }
  
  public void setCategory(String category) {
      this.category = category;
  }
  
  public String getUid() {
      return uid;
  }
  
  public void setUid(String uid) {
      this.uid = uid;
  }
  
  public ArrayList&lt;ArrayList&lt;String&gt;&gt; getColor() {
      return color;
  }
  
  public void setColor(ArrayList&lt;ArrayList&lt;String&gt;&gt; color) {
      this.color = color;
  }
  
  }
  </code></pre>
  
  <p>message from my logcat:</p>
  
  <blockquote>
    <p>D/MultipleColorFragment color set size: 0<br>
      java.lang.NullPointerException: Attempt to invoke virtual method 'boolean >     >   java.util.ArrayList.add(java.lang.Object)' on a null object reference </p>
  </blockquote>