简体   繁体   中英

How to share simple beans between activities?

I have aa simple Java bean that gets filled in my second activity. When I return back to my first activity(main activity) I want to have access to this data. But so far I have no idea how to do it.

Can anyone provide me with a code example of how to pass beans between Activities?

Kind regards

Shared Preferences if you have string data

http://developer.android.com/guide/topics/data/data-storage.html#pref

Singleton class if you have objects to pass around.

If you want guaranteed persistance use database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM