I want to know exact ,
- whether should I used
parcelableorserializationtechnique
for sending data from one activity to other? - is it compulsory to
use one of them for sending data from one to other? - when should I use them?
- and the exact difference between them and performance
of both of them in java aspects.
Thanks in advance.
public class GetSetClass implements Serializable {
private int dt = 10;
/** pass any object, drwabale */
public int getDt() {
return dt;
}
public void setDt(int dt) {
this.dt = dt;
}
}
If you are sending a non-primitive type data/Object to another activity through the
intentyou have to eitherSerializeor implementParcelablefor that object. The preferred technique isParcelablesince it doesn’t impact the performance.It is only compulsory/used for sending non-primitive type data objects.
Serialization does impact the performance. For more details check this link Android Parcelable and Serializable