It's not a secret anymore!*
The moose likes Android and the fly likes Passing data among Activities Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Passing data among Activities" Watch "Passing data among Activities" New topic

Passing data among Activities

Jake Reynolds

Joined: Mar 10, 2009
Posts: 12
I've got an idea for an application, but it's going to end up having a lot of variables that I'd like to stay static, both across application launches and Activities (I can think of at least two that I'd be using). What's the best way to handle this? A single row sqlite db? Writing the variables out to a file? Creating an object to hold them then pass it to the activities, and serialize it on pause?


Monu Tripathi

Joined: Oct 12, 2008
Posts: 1369
    1 has methods called getExtras(..) and putExtras(..) that you can use to pass data around. You can use android.os.Bundle to pass data between activities(it is serializable too).

[List of FAQs] | [Android FAQ] | [Samuh Varta]
Jake Reynolds

Joined: Mar 10, 2009
Posts: 12
Ohhhh, I saw that put to work in Hello, Android and hadn't even thought of it... Thanks!
I agree. Here's the link:
subject: Passing data among Activities
Similar Threads
JMS connection factory
Images and icon preferred size
binding and unbinding and rebinding events in jQuery
Home Button
Best practices for storing state data "outside" of the Activity