title: how to access list of fragment from another activity?
body: <p>I have a fragment which has list of items. I want to access that list from another activity which adds items in list as user enters in edit text and saves the item. this item should get added in the list of fragment. How can I achieve this?? How can I access List created in the fragment from another activity?</p>
  
  <p>Fragment</p>
  
  <pre><code>public class ItemFragment extends Fragment {
  
      RecyclerView recyclerView;
  
      IAdapter adapter;
      ArrayList&lt;Expense&gt; items;
  
      public ItemFragment() {
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_item_list, container, false);
          setHasOptionsMenu(true);
          Expense e = new Expense();
  
          recyclerView = (RecyclerView) view.findViewById(R.id.RecyclerView);
          ImageButton imageButton = (ImageButton) view.findViewById(R.id.imgbtn_fab);
          LinearLayoutManager llm = new LinearLayoutManager(this.getActivity());
  
  
          items=new ArrayList&lt;&gt;();
          recyclerView.setLayoutManager(llm);
  
          recyclerView.setHasFixedSize(true);
  
          initializeDataType1();
          adapter = new IAdapter(getActivity(),items);
          recyclerView.setAdapter(adapter);
  
  
          imageButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  Intent intent = new Intent(ItemFragment.this.getActivity(), Main2Activity.class);
                  startActivity(intent);
  
  
              }
          });
          return view;
      }
  
      private void initializeDataType1() {
  
          items.add(new Expense("1000", "2000", 1));
          items.add(new Expense("2000", "5000", 1));
          items.add(new Expense("3000", "400", 2));
          items.add(new Expense("1000", "4000", 1));
          items.add(new Expense("3000", "3000", 2));
          items.add(new Expense("2000", "100", 1));
          items.add(new Expense("2000", "3333", 2));
          items.add(new Expense("3000", "shopping", 1));
          items.add(new Expense("1000", "food", 1));
          items.add(new Expense("1000", "food", 2));
          items.add(new Expense("2000", "drink", 1));
          items.add(new Expense("3000", "shopping", 2));
          items.add(new Expense("2000", "3333", 1));
          items.add(new Expense("3000", "shopping", 1));
          items.add(new Expense("1000", "food", 1));
          items.add(new Expense("1000", "food", 1));
          items.add(new Expense("2000", "drink", 1));
          items.add(new Expense("3000", "shopping", 1));
      }
  }
  </code></pre>
  
  <p>Activity</p>
  
  <pre><code>public class Main2Activity extends Activity {
  
      public Expense ex;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main2);
  
          final EditText amt=(EditText)findViewById(R.id.editText);
         final  EditText exp=(EditText)findViewById(R.id.editText2);
        final  EditText typ=(EditText)findViewById(R.id.typ);
  
  
          Button save=(Button)findViewById(R.id.addamt);
  
  
          save.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  String amount = amt.getText().toString();
                  String expense = exp.getText().toString();
                  int type=(Integer.parseInt(typ.getText().toString()));
  
                  Toast.makeText(getApplicationContext(),
                          "Saved",
                          Toast.LENGTH_LONG).show();
  
  
              }
          });
  
      }
  }
  </code></pre>
  
  <p>Please help...</p>