android-static arraylist
<p>How can I retrieve one activity arraylist into another activity and store,update and clear? </p>

<p>I have attached my class activity1 and activity2.In activity1 i used arraylist - arr_remark.In activity2 i want to retrieve the arraylist data and as well as clear also.</p>

<p>Activity 1:  </p>

<pre><code>public class Prospect_Remarks extends Activity{

    public static ArrayList&lt;String&gt; arr_remark= new ArrayList&lt;String&gt;(); 

            public static ArrayList&lt;String&gt; aList = null;

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.remarks);

                .......              
                .......

        btn_done=(Button) findViewById(R.id.btn_done);
        btn_done.setOnClickListener(new OnClickListener() {
        @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub          
            arr_remark.clear();         
            arr_remark.add(txt_remarks.getText().toString());
            setList(arr_remark);
            finish();
            }       
        });

    }   
    @Override
    protected void onStart() {
            super.onStart();

        if(!arr_remark.isEmpty())   
        {
            arr_remark=getList();
            txt_remarks.setText(arr_remark.get(0));
        }    
    }
    public void setList(ArrayList&lt;String&gt; aList)
    {
         this.aList = aList;
    }
    public ArrayList&lt;String&gt; getList () 
    {
         return aList;
    }   
}


Activity 2:



 public class Prospects_add extends Activity{


        public static ArrayList&lt;String&gt; arr_list= new ArrayList&lt;String&gt;(); 

        Prospect_Remarks prospect_remarks=new Prospect_Remarks();


        /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.prospects_add);


            btn_save.setOnClickListener(new OnClickListener() {         
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Function_Insert_Update_Delete(v,"ADD"); 
                }
            });     

        }

        public void show_remarks(View v){
            // TODO Auto-generated method stub      
            String[] rmk={};        
            new_window=new Intent(v.getContext(),Prospect_Remarks.class);
            new_window.putExtra("Remarks",rmk);
            startActivityForResult(new_window,3);
        }    

        @Override
        protected void onStart() {
                super.onStart();
                Load_Details();         
        }

           private void Load_Details() {
            // TODO Auto-generated method stub
            Clear_Details();
            if (row_id&gt;0)
            {                   

                dbAdapter.openDataBase();
                Cursor c = dbAdapter.selectRecordsFromDB("SELECT * FROM tbProspect where id="+row_id, null);
                c.moveToFirst();

                            prospect_remarks.getList();
                arr_list.add(c.getString(c.getColumnIndex("Remarks")));
                prospect_remarks.setList(arr_list);

      }

        }       
        protected void Function_Insert_Update_Delete(View v, String sType) {

         // TODO Auto-generated method stub
         dbAdapter.openDataBase();
         long lStatus;
         long lIs_Found;

         if (sType.equals("ADD")|| sType.equals("MOD"))
         {

            if (sType.equals("ADD"))
            {

            if(lIs_Found==0)
            {   

                if(prospect_remarks.arr_remark.isEmpty())
                {            
                  initialValues.putNull("Remarks");
                }
                else
                {               
                 initialValues.put("Remarks",prospect_remarks.arr_remark.get(0));
                }

                if (sType.equals("ADD"))
                {
                    lStatus= dbAdapter.insertRecordsInDB("tbProspect", null, initialValues);                
                    if (lStatus==0)
                        alert_Message("Info","Error in addition.","Ok","Cancel",false);                 
                    else                    
                        close_window();
                }
                else
                {
                    lStatus = dbAdapter.updateRecordsInDB("tbProspect", initialValues,"id="+row_id,null);
                    close_window();
                }
            }
            else
            {
                alert_Message("Info","Duplicate prospects exist.","Ok","Cancel",false);         
            }
        }   
        dbAdapter.close();
      } 

      private void Clear_Details()
      {   
         prospect_remarks.arr_remark.clear();
         contact_details.arrList.clear();
      } 

      private void close_window(){
                if (dbAdapter != null) 
                {
                    dbAdapter.close();
                }
                finish();
      }   
</code></pre>

<h2>        }</h2>

<p>Thanks in advance.</p>
