I have an Arraylist
of custom objects. I am trying to pass it from one java file to another. I tried the putExtra
method and the Parcelable
option; but I'm unable to understand Parcelable
.
Here's my custom object:
public class AddValues implements Serializable{
public int id;
String value;
public AddValues(int id, String value)
{
this.id = id;
this.value = value;
}
@Override
public String toString() {
String result = "id = "+id+","+" value = "+value;
return result;
}
public int getid()
{
return this.id;
}
public String getvalue()
{
return this.value;
}
}
And here's my code to send the ArrayList
:
Intent intent = new Intent(BluetoothLeService.this,HomePageFragment.class);
intent.putExtra("id", data_id);
intent.putExtra("value", list);
Here "list" refers to the ArrayList
.