How do I pass data between activities in Android?


Jan 26, 2013    Janaki Mahapatra, Android

Add the following code in your current activity
Intent i = new Intent(getApplicationContext(), NewActivity.class);
i.putExtra("new_variable_name","value");
startActivity(i);


Then in the new Activity, retrieve those values:
Bundle extras = getIntent().getExtras();
if (extras != null) {
    String value = extras.getString("new_variable_name");
}