-1

I want to pass data from Activity1 to Activity2 and then Data of Activity1 and Activity2 combined in Activity3. how am i supposed to do it Android Studio?

Akash Nair
  • 27
  • 8
  • Possible duplicate of [What is a "bundle" in an Android application](https://stackoverflow.com/questions/4999991/what-is-a-bundle-in-an-android-application) – Tim Biegeleisen Aug 07 '18 at 13:41
  • 1
    Please spend some time researching your question before posting. In life, you should generally not expect others to do work for you ;-) – Tim Biegeleisen Aug 07 '18 at 13:42

1 Answers1

0

You can use intent extras to do this. Intent extras use a key/value pair system to store data. For example to put data you would say:

String name = "John Doe";
Intent intent = new Intent(this, Activity2.class);
intent.putExtra("myData", name);
startActivity(i);

Then in Activity2, you would retrieve the intent, and then get your data back:

Intent intent = getIntent();
String name = intent.getStringExtra("myData");

Now inside of this variable name, you will find "John Doe"

  • how do i then then pass data to Activity3 of Activity1 and Activit2 Combined? – Akash Nair Aug 08 '18 at 08:30
  • Theoretically, you could pass an array or custom object from Activity1 to Activity2, then append whatever data you want from Activity2 onto the array/object and then pass that onto Activity3. Maybe you should even look into something like Paper db or Shared preferences – Vineet Sridhar Aug 10 '18 at 17:18