title: Firebase getValue(Class.class) Object
body: <p>I am trying to get data from Firebase into an Object but it is returning null for the values.</p>
  
  <p>My Firebase database is as follows:</p>
  
  <pre><code>- Reports
      - RandomID
          - Name: Bob
          - Value: x
  </code></pre>
  
  <p>etc</p>
  
  <p>My Report Class is as follows:</p>
  
  <pre><code>public class Report {
      private String name;
      private String value;
  
  
      public Report() {
      }
  
      public Report(String name, String value) {
          this.name= name;
          this.value= value;
      }
  
      public String getName() {
          return name;
      }
  
      public String getValue() {
          return value;
      }
  
      public void setName(String name) {
          this.name= name;
      }
  
      public void setValue(String value) {
          this.value= value;
      }
  </code></pre>
  
  <p>I have a database addChildEventListener in which on the onChildAdded method i do the following:</p>
  
  <pre><code>mDatabase = FirebaseDatabase.getInstance().getReference().child("Reports");
  mDatabase.addChildEventListener(new ChildEventListener() {
              @Override
              public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                      Report currentReport = dataSnapshot.child(s).getValue(Report.class);
                      Log.d("CurrentReport", "Name: "currentReport.getName() + " Value: " + currentReport.getValue()));
                      Log.d("MyReports", dataSnapshot.getValue().toString());
  </code></pre>
  
  <p>the <code>currentReport.getName()</code> and <code>getValue()</code> are returning null
  but <code>dataSnapshot.getValue().toString()</code> is returning:
      <code>{Name=Bob, Val= x}</code></p>
  
  <p>How can i store this in Report without doing Report x = new Report(...)</p>
  
  <p>Thanks</p>