How to pass an arraylist of data from one GridView in one activity to another GridView in a second activity in java android.We are trying to see how to pass complex data like an arraylist between activities.

Most android applications, atleast serious ones, comprise more than one activity. Activities in android User interface units. We need a way of then passing data from one activity to another.Thats this lessons aim. The aim is to see how to pass Strings,Integers and Booleans, primitive data types from one activity to another using Intent.Here's the thing :

  • Pass integers,booleans and string from one activity to another.
  • The booleans shall be represented in a checkbox,the string in an edittext while the integer also in an edittext.
  • The user enters them in our MainActivity,we pass them via intent, and show them in second activity.
  • We use intents.

Android Data Passing - From TextBox To Second Activity tutorial.

Passing data between activities is a common task. This is especially because of what an activity means for android applications.

In fact data passing between entities is something that is not only fundamental to android applications but also to other types of applications.

Given that Java is an Object Oriented Programming language, and activity itself is a class, android beginners at first try to pass data in the usual way via constructors.

However, this cannot work in android since an activity itself is a special class representing screen that users can interact with.

Activities have a Context as well as lifecycle methods, making it a complex entity that has special way of working with.

If you need several pages within your application you may need several activities. Another approach is to have several fragments hosted by the same activity. However that is for another day.