I know that I can add a string or an integer by putting putextra() on my Intent but what do I do if I have to send a List? For example, My main activity contains a list, I have a different activity that adds an item into the list and I have a third activity that needs to show the whole list
-
1I'm always a bit surprised and somewhat appalled when someone asks how to do a particular programming task "in Android Studio". Android Studio is your IDE - i.e. you editor. You are working in the Java programming language, with the Android class libraries. This is like someone trying to write a novel, and asking about how to handle a particular plot turn "in MS Word". – GreyBeardedGeek Oct 04 '15 at 01:42
2 Answers
Your object can also implement Parcelable interface. Then you can use Bundle.putParcelable()
method and pass your object between activities within intent.
Photostream application uses this approach and may be used as a reference http://code.google.com/p/apps-for-android/
Source: google "pass objects between activities android" :)

- 53,191
- 11
- 86
- 129
By making the Activity the central focus of the Android API, both in the API documentation and in most of their examples, Google has encouraged inexperienced developers to treat Activities as the sole constructs in an Android application. And, unfortunately, most of the widely available literature and over-simplified code examples available on the web perpetuate this.
However, good software design, regardless of platform or programming language, would suggest that you use the concept of a data 'model' - a class that contains the data that is important to your application, as well as methods that operate on that data. This class should be independent of any user-interface-related classes.
Activities are essentially a mash-up of Views and Controllers from the point of view of the popular Model-View-Controller (a.k.a. MVC) design pattern.
You should strive to remove the management of your data from the Activities, and put it elsewhere, in a non-Android class. Then make that class available to the Activities that need it, instead of simply passing data from Activity to Activity.
Where to put this model class? There are a number of ways to do it, including, but not limited to:
- Make it a member of your Application class (subclass Application if you haven't already) - this is simple and convenient, but only reasonable for very small applications - it quickly gets out of hand
- Make it stand-alone, but make all of the data members and methods static - again, simple and convenient, but only for a very small amount of data
- Use a dependency injection library (e.g. Dagger), make it a Singleton, and inject into the Activities that need it.

- 29,460
- 2
- 47
- 67