title: Android - Getting an Object from DataSnapShot - firebase database
body: <p>I created a helper class including the functions and processes I would like to perform over my data in FirebaseDatabase.</p>
  
  <p>The following function was meant to get all Posts in posts Node in fireabseDataBase:</p>
  
  <pre><code>public static Jobs getAllJobs() {
  
      Posts posts= new Posts();
      postsDBRef= FirebaseDatabase.getInstance().getReference("posts").getRef();
  
      postsDBRef.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              for (DataSnapshot jobSnapshot: dataSnapshot.getChildren()) {
                  // TODO: handle the post
                 String key = jobSnapshot.getKey();
                 //here 
                 Post post= jobSnapshot.child(key).getValue(Post.class);
                // and here  
                 posts.add(post);
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
              Log.i(getClass().getName().toString(), ": " + databaseError.getMessage());
          }
      });
  
      return posts;
  }
  </code></pre>
  
  <p>in the <code>onDataChange</code> function I am trying to loop over the data and retrieve it, although while logging I do get data but the post object keeps giving Null</p>
  
  <p>Here's How the data look like in firebase DataBase </p>
  
  <pre><code> {
    "posts" : {
      "-Kr9-ii-ArpC3fLuuGnb" : {
        "address" : "sfhhfg",
        "applied" : false,
        "currency" : "le",
        "description" : "ehdhyf",
        "latitude" : 0,
        "longitude" : 0,
        "noOfWorkers" : 2,
        "rating" : 0,
        "reported" : false,
        "salary" : "1250",
        "title" : "rgchu",
        "userId" : 0
      },
      "-Kr94BDkdEZrmxmjxv_Z" : {
       /../
      },
      "-Kr9Dz3S0BQEYv4VO2l3" : {
     /../
      },
      "-Kr9XqDPUvCRcv0lwFy_" : {
      /../
      }
    }
  }
  </code></pre>
  
  <p>and here’s what am getting from the Debugger in a single loop</p>
  
  <blockquote>
    <p>DataSnapshot { key = -Kr9-ii-ArpC3fLuuGnb, value = {address=sfhhfg,
    rating=0, title=rgchu, reported=false, description=ehdhyf, userId=0,
    longitude=0, noOfWorkers=2, latitude=0, currency=le, applied=false,
    salary=1250} }</p>
  </blockquote>
  
  <p>Any idea what am I doing wrong?</p>