-1

I new to android studio and java in general. I am wondering if there is a good way to send data to multiple activities. I have 6 activities in my app right now, on the first activity the user will enter text. I have figured out how to make this text go from the first activity to the second activity. But I also want this text to show up on my 6th activity which is a summary page. Is there an easy way to do this?

Thanks in advance!

Ratish Bansal
  • 1,497
  • 1
  • 9
  • 19

2 Answers2

1

You might want to try SharedPreferences, which saves information into the phone.

From Android guides:

If you don't need to store a lot of data and it doesn't require structure, you should use SharedPreferences. The SharedPreferences APIs allow you to read and write persistent key-value pairs of primitive data types: booleans, floats, ints, longs, and strings.

You can find more than enough tutorials online. Some of them are:

S. Czop
  • 494
  • 5
  • 16
0

S. Czop is right, check this:

Setting values in Preference:

// MY_PREFS_NAME - a static String variable like: 
//public static final String MY_PREFS_NAME = "MyPrefsFile";
SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit();
 editor.putString("name", "Elena");
 editor.putInt("idName", 12);
 editor.apply();

Retrieve data from preference:

SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); 
String restoredText = prefs.getString("text", null);
if (restoredText != null) {
  String name = prefs.getString("name", "No name defined");//"No name defined" is the default value.
  int idName = prefs.getInt("idName", 0); //0 is the default value.
}

Source: Android Shared preferences example

Saltae
  • 183
  • 1
  • 2
  • 11