Andriod Parcelable Example
//create object of empty constructor and all is done
//when using intent DataModel usr = (DataModel) intent.getParcelableExtra("abc");
public class DataModel implements Parcelable {
String firstName, lastName;
public DataModel() {
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
// parcelling part
public DataModel(Parcel in) {
firstName = in.readString();
lastName = in.readString();
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(firstName);
dest.writeString(lastName);
}
public static final Parcelable.Creator<DataModel> CREATOR = new Parcelable.Creator<DataModel>() {
@Override
public DataModel createFromParcel(Parcel source) {
return new DataModel(source);
}
@Override
public DataModel[] newArray(int size) {
return new DataModel[size];
}
};
}