Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Lists and Adapters (2015) Using Parcelable Data Reading Parcelable Data

i think this is editor issue ...

ive referenced http://developer.android.com/reference/android/os/Parcelable.html and it doesnt work ??? any ideas

public class VideoGame implements Parcelable {

    public String mTitle = "";
    public int mYear = 0;

    public VideoGame() {
        // intentionally blank

    // getters and setters omitted for brevity!

    public int describeContents() {
        return 0;

    public void writeToParcel(Parcel dest, int flags) {

    public VideoGame(Parcel in) {
        // Task 1 code here!

    public static final Creator<VideoGame> CREATOR = new Creator<VideoGame>() {
        public VideoGame createFromParcel(Parcel source) {
            // Task 2 code here!
            return new VideoGame(source); // i dont get why  this is not working???

        public VideoGame[] newArray(int size) {
            // Task 3 code here!
            return new VideoGame[0];

3 Answers

william parrish
william parrish
13,774 Points

Task 2 is correct, you are not doing anything wrong there.

Task 1 is not correct ( even though it allowed you to proceed, this is a big and they should / will likely fix it )

Task 1 being incorrect, causes the constructor in task 2 to fail.

To fix task 1:

You need to read the values from the parcel, and assign them to mTitle and mYear.

for example

mTitle = parcel.readString(); mYear = parcel.readInt();

when you do this correctly step two will pass, and you should be good to go.

thanks will i submitted a bug but have a look over at this link http://developer.android.com/reference/android/os/Parcelable.html it is also quite misleading lol and i got the task done before i saw this post thanks man

william parrish
william parrish
13,774 Points

Therein lies the rub,

On DAC the big difference that allows their example to work is addition of a separate constructor, that handles object creation from a parcel.

 private MyParcelable(Parcel in) {
     mData = in.readInt();

The absence of a parcel specific constructor in the above coding exercise, is the reason you have to set those fields yourself.

Anywho, glad you got sorted all the same.