multithreading - Android Development: Storing data accross activities -
as mentioned before i'm starting out android development, having got head around moving activity activity. i'm wondering whats best way store info can used when needed on various activities.
coming web development background, i'm thinking upon bit having info stored in session or cookie. exists in background , can accessed when needed. (i aware utilize db, avoid using 1 if possible particular app)
for arguments sake, wanted have linkedlist of employee objects persistent across multiply activities. if created said linkedlist in worker thread, thread exist lifetime of application, allowing info available ui thread @ point?
thanks
on object-oriented development view i'd want pretty simple:
on mainactivity, activity started @ origin of lifetime of application, have linkedlist
public class mainactivity extends application { private linkedlist<employee> employees = new linkedlist<employee>(); public linkedlist getemployees() { homecoming this.employees; }
in sec activity:
public class seconactivity extends activity { private mainactivity app; private linkedlist<employee> emp; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.app = (mainactivity) getapplication(); this.emp = app.getemployees();
for little amount of info across application utilize sharedpreferences class.
android multithreading
No comments:
Post a Comment