I have set a value in spinner , from activity-1.
now i am traversing to activity-2 and again coming back to activity-1, i am not getting the updated spinner value which i have selected previously but i am getting default value(value at index 1) of spinner .
I have set a value in spinner , from activity-1. now i am traversing
Share
An
Activitythat becomes inactive (invisible to a user) can be destroyed by the system in case of lacking resources. To keep values betweenActivityruns you need to save your state using Bundles. If you look closely toActivity::onCreatemethod you can see it has a parameter:So, eg in method
onPause()you save your desired values and whenActivityis recreated – load them.Android documentation contains a chapter how to save states between
Activityruns.