title: com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type
body: <p>I'm having a bit trouble retrieving data from FirebaseDatabase.</p>
  
  <p>I think I have done every thing in a correct manner but still This error pops up and crashes the app.</p>
  
  <pre><code>com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type com.rana.sahaj.myyu.profile.ExtraProfilClass
  </code></pre>
  
  <p><strong>ExtraProfilClass</strong></p>
  
  <pre><code>@IgnoreExtraProperties
  public class ExtraProfilClass {
  private String branch;
  private String campus;
  private String course;
  private String gplusURL;
  private String hashname;
  private String picurl;
  private String picurl50DP;
  private String userEmail;
  private String userNAME;
  private String yearFrom;
  private String yearTo;
  public ExtraProfilClass(){
      //Empty constructor for firebase
  }
  
  
  public ExtraProfilClass(String branch, String campus, String course, String gplusURL, String hashname, String picurl, String picurl50DP, String userEmail, String userNAME, String yearFrom, String yearTo) {
      this.branch = branch;
      this.campus = campus;
      this.course = course;
      this.gplusURL = gplusURL;
      this.hashname = hashname;
      this.picurl = picurl;
      this.picurl50DP = picurl50DP;
      this.userEmail = userEmail;
      this.userNAME = userNAME;
      this.yearFrom = yearFrom;
      this.yearTo = yearTo;
  }
  
  public String getBranch() {
      return branch;
  }
  
  public void setBranch(String branch) {
      this.branch = branch;
  }
  
  public String getCampus() {
      return campus;
  }
  
  public void setCampus(String campus) {
      this.campus = campus;
  }
  
  public String getCourse() {
      return course;
  }
  
  public void setCourse(String course) {
      this.course = course;
  }
  
  public String getGplusURL() {
      return gplusURL;
  }
  
  public void setGplusURL(String gplusURL) {
      this.gplusURL = gplusURL;
  }
  
  public String getHashname() {
      return hashname;
  }
  
  public void setHashname(String hashname) {
      this.hashname = hashname;
  }
  
  public String getPicurl() {
      return picurl;
  }
  
  public void setPicurl(String picurl) {
      this.picurl = picurl;
  }
  
  public String getPicurl50DP() {
      return picurl50DP;
  }
  
  public void setPicurl50DP(String picurl50DP) {
      this.picurl50DP = picurl50DP;
  }
  
  public String getUserEmail() {
      return userEmail;
  }
  
  public void setUserEmail(String userEmail) {
      this.userEmail = userEmail;
  }
  
  public String getUserNAME() {
      return userNAME;
  }
  
  public void setUserNAME(String userNAME) {
      this.userNAME = userNAME;
  }
  
  public String getYearFrom() {
      return yearFrom;
  }
  
  public void setYearFrom(String yearFrom) {
      this.yearFrom = yearFrom;
  }
  
  public String getYearTo() {
      return yearTo;
  }
  
  public void setYearTo(String yearTo) {
      this.yearTo = yearTo;
  }
  }
  </code></pre>
  
  <p>and the code for retrieving is</p>
  
  <pre><code> @Override
      public void onChildAdded(DataSnapshot dataSnapshot, String s) {
        // Map&lt;String, String&gt; msg = (HashMap&lt;String, String&gt;)dataSnapshot.getValue();
   --&gt;       ExtraProfilClass extraProfilClass=dataSnapshot.getValue(ExtraProfilClass.class);
  
      //    String userEmail_here=extraProfilClass.getUserEmail();
     //     userEmailKey = userEmail_here.substring(0, userEmail_here.length() - 10);
  </code></pre>
  
  <p>So.. I fixed the problem. I was not using correct node reference, my bad </p>
  
  <p>(Fix as requested by Shubhank) </p>
  
  <p>Problem was that i wanted to get the <strong>profile node</strong> of user1</p>
  
  <pre><code>public static DatabaseReference mFirebaseRef = FirebaseDatabase.getInstance().getReferenceFromUrl(constants.FIREBASE_URL+"app/authGplus/users/");
  </code></pre>
  
  <p>so what i did was:
  <code>mFirebaseRef.child(UserToWhichProfileIsNeeded).child("profile").addChildEventListener(listener);</code></p>
  
  <p>but as i am calling <code>addChildEventListener</code></p>
  
  <p>it already <strong>refers to child node</strong> so i don't need to put  <code>.child("profile")</code> during refernce and it would become like this,</p>
  
  <p><code>mFirebaseRef.child(UserToWhichProfileIsNeeded).addChildEventListener(listener);</code></p>
  
  <p>and then it worked fine.</p>