Created
July 9, 2018 09:44
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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