You can use onSaveInstanceState
void onSaveInstanceState(Bundle out) {
String val = ...
out.putString("MYVALUE", val);
super.onSaveInstanceState(val);
}
Then
void onCreate(Bundle savedState) {
if(savedState != null) {
String val = savedState.getString("MYVALUE");
}
}
Or do you mean how to put data for another activity? Then you can do
Intent i = new Intnet(this, OtherActivity.class);
String val = ...
i.putExtra("MYVALUE", val);
startActivity(i);
Then in the other activity
void onCreate(Bundle savedState) {
...
Intent i = getIntent();
String val = i.getStringExtra("MYVALUE");
}
solved Using Intent while saving data of previous Activity