Android - How does one Activity access variables in another Activity? -


what best way this?

is possible through static variables?

case: given 2 activities (main , main2), if want keep changes make on main2 (using intent), need save changes in main (with static vars) can retrieve them later in main2 again?

generally shouldn't rely on storing persistent data in activity. each activity cycles through lifecycle changes out of control. shouldn't store static variables in activities want other activities access.

you can use sharedpreferences api store user preferences.

if need store application-wide values each of activities can access, consider storing them in class extends application class, or create static singleton store them in.

edit: here discussion involving use of application class versus using static singleton store global application state.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -