How i can access ArrayList from one Activity to another and also clear ArrayList value and store & retrieve it to database?
Sample Code:
**Activity 1:**
public static ArrayList<String> arrList =new ArrayList<String>();
arrList.clear();
arrList.add(0,txt_phone1.getText().toString());
arrList.add(1,txt_phone2.getText().toString());
finish();
**Activity 2:**
dbAdapter.openDataBase();
Cursor c = dbAdapter.selectRecordsFromDB("SELECT * FROM tbProspect where id="+row_id,null);
c.moveToFirst();
contact_details.arrList.add(c.getString(c.getColumnIndex("Phone1")));
contact_details.arrList.add(c.getString(c.getColumnIndex("Phone2")));
c.close();dbAdapter.close();
The best way to that is to create a singleton of your shared objects, and get/set your objects when needed from anywhere in your application.
Just remember to call
getInstance()at theonCreate()of eachActivity.