Use same data in every activity using tab in android
I want to use same data in every activity when I changed tab. I want to set spinner data in 1st tab开发者_如何学Python and get that data when tab changed.
How can is possible?
Thanks.
There was many way like
- Store the into the SharedPreference
- Make General class and store in that.
- Pass the Intent with the bundle of information.
If the data was small then prefer the SharedPreference object which you can get in all the Activity.
If the data are large then create the General class which contain the the static member and assigning that data value to the appropriate object. But avoid the get/set method in android. See more detail about performance
and the last if the data is small and you want to pass through the activity you can set into the Bundle object and set into the Intent.
you can use a sharedpreference with a sharedpreference listener, or some contentobserver, or some custom notification system. There are lots of possibilities
精彩评论