Question: I'm new to android studio and going through intents. I'm creating a registration app which takes user information in first 4 activities and display them altogether in respective views the 5th activity.

My app has personal, professional,address and other detailed activities that are to be retrieved from edit texts and later displayed on the very last screen.

I can only retrieve data only on the next consecutive screen but not save them and add to last activity later on. 

Is there any way that i can do the storing and retrieving part using only intents between 2 activities that are not consecutive to each other ? Any help will be appreciated...!!

Answer: 
Yes you can do so by sending the data form one activity to the other activity in chain. 

Let say your app starts at **ActivityOne** then goes to **ActivityTwo** then to **ActivityThree** then to **ActivityFour** then to **ActivityFive** and submits the data here in ActivityFive. Each activity has a EditText to enter data and a button which on clicking goes to the next activity.

In **ActivityOne** create and then start an intent on the button click i.e. inside onClick():

```
Intent i = new Intent(ActivityOne.this,ActivityTwo.class);
i.putExtra("Name",edittext.getText().toString());//get sting from 1st edittext
startActivity(i);

```

Now your second activity has been started i.e. **ActivityTwo**.

In that activities onCreate() method create an Intent`Intent a = getIntent();`

Now in onClick method for the button of this activity do the following:

```
Intent i = new Intent(ActivityTwo.this,ActivityThree.class);
i.putExtra("Address",edittextTwo.getText().toString());//This line fetches the data from the activities edittext
i.putExtra("Name", a.getStringExtra("Name"));//This line fetches the data from the intent which called this activity.
startActivity(i);

```

Now in the third activity which has been started i.e. **ActivityThree**.

Do the same thing in the activities onCreate() method i.e. create an Intent`Intent a = getIntent();`

Now in onClick method for the button of this activity do the same thing that you did previously but also fetch the data passed from the previous activity:

```
Intent i = new Intent(ActivityThree.this,ActivityFour.class);
i.putExtra("email",edittextThree.getText().toString());//This line fetches the data from the activity's edittext
i.putExtra("Name", a.getStringExtra("Name"));//This line fetches the data from the intent which called this activity.
i.putExtra("Address", a.getStringExtra("Address"));//This line fetches the data from the intent which called this activity.
startActivity(i);

```

Continue this in all the activities and in the end you will be able to get all the data in the final activity.

The logic here is to pass the data from one activity to the other and keep on adding data on the go.
```
    You can use singleton class 
    Create one model class and add the data from that four activites

        public class MySingleton {
        private UserModel user_details;

        private static MySingleton ourInstance = new MySingleton();

        public static MySingleton getInstance() {
            return ourInstance;
        }

        private MySingleton() {
        }

     public void setUserDetails(UserModel news) {
            this.user_details= news;
        }

        public UserModel getUserDetails() {
            return user_details;
        }
    }

//add user details
MySingleton mysingleton= MySingleton .getInstance();
mysingleton.setUserDetails(userdetails); // userdetails - model class object

```