Reputation: 18712
In my application, I have one activity, which connects to the server and gets certain user information from it. Then, it launches another activity where that information should be processed.
What is the correct way to pass data between activities in Android?
Upvotes: 0
Views: 56
Reputation: 4328
If that data is only needed once, you should use an Intent
. Here is a tutorial on it.
If it needs to be accessed all the time, you can put it in an Application
subclass or some other singleton.
In general you can use methods like putExtra
, to attach data to an Intent, and then use
for example getIntent().getStringExtra(name)
to retrieve it in the other activity.
Upvotes: 3