Skip to content

Instantly share code, notes, and snippets.

@ramakrishnajoshi
Created July 9, 2018 09:44
Show Gist options
  • Save ramakrishnajoshi/3775c5517f8a91f1404692269b7141e6 to your computer and use it in GitHub Desktop.
Save ramakrishnajoshi/3775c5517f8a91f1404692269b7141e6 to your computer and use it in GitHub Desktop.
Parcelable Interface is used to send data objects from one activity to another activity.
public class StudentDataClass implements Parcelable {
public String studentId;
public String studentName;
public StudentDataClass(String studentId, String studentName) {
this.studentId = studentId;
this.studentName = studentName;
}
protected StudentDataClass(Parcel in) {
studentId = in.readString();
studentName = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(studentId);
dest.writeString(studentName);
}
public static final Creator<StudentDataClass> CREATOR = new Creator<StudentDataClass>() {
@Override
public StudentDataClass createFromParcel(Parcel in) {
return new StudentDataClass(in);
}
@Override
public StudentDataClass[] newArray(int size) {
return new StudentDataClass[size];
}
};
@Override
public int describeContents() {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment