I wish to pass the value from 1st activity to 3rd activity.
My 1st activity: CustomizedListview
2nd activity is: SingleMenuItemActivity
3rd activity
Use SharedPreferences (for small data)to store the data and get this data in you 3 activity otherwise use internal storage or database(for large data)
//your 1st activity (CustomizedListview)
String str=txtView.getText().toString();
Intent i=new Intent(getApplicationContext(),SingleMenuItemActivity.class);
i.putExtra("message",str);
startActivity(i);
//your 2nd Activity (SingleMenuItemActivity)
String str= getIntent().getStringExtra("message");
Intent i = new Intent(getApplicationContext(), InsertionExample.class);
i.putExtra("message", str);
startActivity(i);
//you 3rd Activity (InsertionExample)
Intent int=getIntent();
String str= int.getStringExtra("message");
txtView.setText(str);
I have to passed orderid value from 1st activity to second activity
Send as you send to second activity . Just change name of second activity to third activity.
Just Store Order Id in Shared Preference and get it in third Activity.
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
prefsEditor.putString("order_id", "5");
prefsEditor.commit();
Get Shared Preference.
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
String prefName = myPrefs.getString("order_id", "0");
Make the value static, and then use it in the 3rd activity
public static int i;
And then, call it on the 3rd activity:
firstActivity.i;
You can use intent extra from first activity to second and then pass the same value by extra in another intent from secon to third.
You can pass the value in 2 ways:
Intent intent = new Intent (this, 2ndActivity.class);
intent.putExtra ("Value",Value);
startActivity(intent);
And the same you can do for 2nd activity to 3rd activity
Bundle extras = getIntent().getExtras();
if(extras!=null){
Values=extras.getString("value");
}