java - Save ArrayList Between activity transtion -
im having lot of trouble here.
problem: have 2 activities , b. in activity have listview custom items. have data of these items storage in arraylist. when user clicks on listview item, activity b called displaying details item. when user comes activity a, items inside listiview gone. know need save listview state, need save data of arraylist.
question: how solve problem?
notes: have tryed onsaveinstancestate , onrestoreinstancestate, since transition between these 2 activities , b fast, activity not destroyed. cannot save arraylist in bundle object. have tryed use sharedprefereces , contentvalues nor of these classes have support parcelable objects , lists.
thanks help!
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); lstview = (listview) findviewbyid(r.id.lstview); connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo ni = cm.getnetworkinfo(connectivitymanager.type_wifi); if (ni != null && ni.isconnected()) updatelistview(); registerclickcallback(); } @override protected void onrestoreinstancestate(bundle savedinstancestate) { super.onrestoreinstancestate(savedinstancestate); listresorces = savedinstancestate.getparcelablearraylist(list_resources); arrayadapter<record> adapter = new bandejaoitemadapter(listresorces); lstview.setadapter(adapter); } @override protected void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); outstate.putparcelablearraylist(list_resources, listresorces); }