title: Key _id expected Parcelable but value was java.lang.Long. while passing Parceable object between Activity
body: <p>I want to pass an object of my custom class to another activity. I came to know that <a href="https://stackoverflow.com/a/2141166/1773155">Parceable is way</a> and <a href="http://www.developerphil.com/parcelable-vs-serializable/" rel="nofollow noreferrer">WAY</a> faster than Serializable. But doing so i get the exception </p>
  
  <p><code>Key _id expected Parceable but value was java.lang.Long. The default value &lt;null&gt; was returned.</code></p>
  
  <p>I don't know what i am doing wrong with it. I followed these tutorials:</p>
  
  <ul>
  <li><a href="http://www.sohailaziz.com/2012/04/passing-custom-objects-between-android.html" rel="nofollow noreferrer">Passing custom objects between android activities</a></li>
  <li><a href="https://stackoverflow.com/a/2141166/1773155">And the one very popular StackOverFlow answer</a></li>
  </ul>
  
  <p>The code of my object that implements <code>Parcelable</code> is as follows:</p>
  
  <pre><code>public class CourseNote implements Parcelable {
  
  private long id;
  private String noteDescription;
  private String noteTitle;
  private String creationDate;
  private String notePic;
  private String noteAudio;
  private String noteVideo;
  private long courseID_FK;
  
  // ---------------------------------------------------------------------------
  
  public CourseNote() {
      super();
  }
  
  // ---------------------------------------------------------------------------
  
  public CourseNote(long id, String noteContent, String noteTitle,
          String creationDate, String notePic, String noteAudio,
          String noteVideo, long courseID_FK) {
      super();
      this.id = id;
      this.noteDescription = noteContent;
      this.noteTitle = noteTitle;
      this.creationDate = creationDate;
      this.notePic = notePic;
      this.noteAudio = noteAudio;
      this.noteVideo = noteVideo;
      this.courseID_FK = courseID_FK;
  }
  
  // ---------------------------------------------------------------------------
  
  // parcel constructor
  public CourseNote(Parcel in) {
      String[] data = new String[8];
  
      in.readStringArray(data);
      this.id = Long.parseLong(data[0]);
      this.noteDescription = data[1];
      this.noteTitle = data[2];
      this.creationDate = data[3];
      this.notePic = data[4];
      this.noteAudio = data[5];
      this.noteVideo = data[6];
      this.courseID_FK = Long.parseLong(data[7]);
  
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      // TODO Auto-generated method stub
      dest.writeStringArray(new String[] { String.valueOf(this.id),
              this.noteDescription, this.noteTitle, this.creationDate,
              this.notePic, this.noteAudio, this.noteVideo,
              String.valueOf(this.courseID_FK) });
  
  }
  
  public static final Parcelable.Creator&lt;CourseNote&gt; CREATOR = new Creator&lt;CourseNote&gt;() {
  
      @Override
      public CourseNote[] newArray(int size) {
          // TODO Auto-generated method stub
          return new CourseNote[size];
      }
  
      @Override
      public CourseNote createFromParcel(Parcel source) {
          // TODO Auto-generated method stub
          return new CourseNote(source);
      }
  };
  
  @Override
  public int describeContents() {
      // TODO Auto-generated method stub
      return 0;
  }
  
  // ---------------------------------------------------------------------------
  
      // I am ignoring setters/getters
  }
  </code></pre>
  
  <p>When the user clicks on the List Item i am sending <code>Parcelable</code> object to other activity, i am doing this in <code>onItemClickListner</code> as follows (However it works fine):</p>
  
  <pre><code>        getListView().setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View view,
                  int position, long id) {
              long selectedNoteId = id;
  
              mIntent = new Intent(getActivity(), AddEditNoteActivity.class);
  
              mCursor = (Cursor) mNoteListAdapter2.getItem(position);
  
              mTempCourseNote = new CourseNote(
                      id,
                      mCursor.getString(mCursor
                              .getColumnIndex(CourseNote.COL_CONTENT)),
                      mCursor.getString(mCursor
                              .getColumnIndex(CourseNote.COL_TITLE)),
                      String.valueOf(mCursor.getLong(mCursor
                              .getColumnIndex(CourseNote.COL_CREATION_DATE))),
                      "", "", "", mCursor.getLong(mCursor
                              .getColumnIndex(CourseNote.COL_COURSE_ID_FK)));
  
              mIntent.putExtra("method", "edit");
              mIntent.putExtra(CourseNote._ID, mTempCourseNote);
              mIntent.putExtra(Course._ID, currentCourseID);
  
              Log.i(StudyManagerDataSource.LOG_TAG, "Going to start activity");
              startActivity(mIntent);
  
          }
      });
  </code></pre>
  
  <p>This is how i am recieving the ParcelAble Object: </p>
  
  <pre><code>CourseNote mTempCourseNote = (CourseNote) getIntent().getParcelableExtra(
                  CourseNote._ID);
  </code></pre>