title: How to retrieve total child from model class and pass in adapter in android?
body: <p>I retrieved data from firebase realtime database and pass it to the adapter and show it in the recyclerview.
  Below image shows my data structure.
  <a href="https://i.stack.imgur.com/UDTGO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UDTGO.png" alt="database structure"></a></p>
  
  <p>lastname,postid and timestamp is succesfully retrieved by model class.
  But I want to retrieve total no. of child of "comments" and pass in adapter.
  Here is my model class.</p>
  
  <pre><code>public class Post
  {
      public String lastname;
      public String postid;
      public long timestamp;
  
      public Postt()
      {
  
      }
  
      public Postt(String lastname, long timestamp, String postid)
      {
          this.lastname=lastname;
          this.timestamp=timestamp;
          this.postid=postid;
      }
  
      public String getPostid() {
          return postid;
      }
  
      public void setPostid(String postid) {
          this.postid = postid;
      }
  
      public long getTimestamp() {
          return timestamp;
      }
  
      public void setTimestamp(long timestamp) {
          this.timestamp = timestamp;
      }
  
      public String getLastname() {
          return lastname;
      }
  
      public void setLastname(String lastname) {
          this.lastname = lastname;
      }
  }
  </code></pre>
  
  <p>And adapter is</p>
  
  <pre><code>List&lt;Post&gt; mPost;
  @Override
  public void onBindViewHolder(@NonNull final PostHolder postHolder, final int i) {
          String posid=mPost.get(i).getPostid();
          String lastname=mPost.get(i).getLastname();
          long timestamp=mPost.get(i).getTimestamp();
  ***//Here i want to get the total no of child of "comments" node.//
  //please dont tell to use ValueEventListner inside onBindViewHolder//***
              }
  </code></pre>
  
  <p>Here is my query in MainActivity</p>
  
  <pre><code>query.addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  List&lt;Post&gt; userModels = new ArrayList&lt;&gt;();
                  for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
                         userModels.add(userSnapshot.getValue(Post.class));
  //Here I want to retrieve no of "comments"child and pass in adapter//
                  }
                  mAdapter.addAll(userModels);
              }
              @Override
              public void onCancelled(DatabaseError databaseError) {
              }
          });
  </code></pre>
  
  <p>For retrieving "comments" total no. of child, how i prepare model class and for loop in query?</p>