1

In my app I have an array

List<Friends> friends =new ArrayList<Friends>();

where Friends is :

import java.io.Serializable;

public class Friends implements Serializable{

private final String name;
private final String id;

public Friends(String name, String id){
    this.name=name;
    this.id=id;
    }
public String getName(){
    return name;
}
public String getId()
{
    return id;
}

}

I want to send this array to an other Activity and I don't know how should I do.

I tried to send them one by one but it not worked. Any idea?

Thanks in advance.

1 Answer 1

3

ArrayList is Serializable, so Bundle.putSerializable("myList", friendList); should be working.

I would advice however to make your Friend class Parcelable, then use Bundle.putParcelableArrayList()

Note that to pass data to another activity, you should use intent extras. See Passing a Bundle on startActivity()?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.