title: Get the data from the Firebase in limit to perform pull to refresh and load more functionality
body: <p>Yet now i am getting the all data from the <code>FireBase</code> at one time.What i want to do that getting data in <strong>LIMITS</strong> like <em>15</em> records at a time. Like in first time user get the 15 records from the <code>Firebase</code> and when user load more data at the bottom/TOP of the screen than 15 more records should come from <code>Firebase</code> and added to the bottom/TOP of the list.<br>
  <br>
  I have implemented the logic to get the 15 records at a top OR bottom of the database from <code>Firebase</code> like below:-</p>
  
  <pre><code>public class ChatActivity extends AppCompatActivity implements FirebaseAuth.AuthStateListener {
  
      private FirebaseAuth mAuth;
      private DatabaseReference mChatRef;
  
      private Query postQuery;
      private String newestPostId;
      private String oldestPostId;
      private int startAt = 0;
      private SwipeRefreshLayout swipeRefreshLayout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_chat);
  
          mAuth = FirebaseAuth.getInstance();
          mAuth.addAuthStateListener(this);
  
          mChatRef = FirebaseDatabase.getInstance().getReference();
          mChatRef = mChatRef.child("chats");
  
           /////GETTING THE VIEW ID OF SWIPE LAYOUT
          swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
  
      /////GETTING FIRST 10 RECORDS FROM THE FIREBASE HERE
          mChatRef.limitToFirst(10).addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  for (DataSnapshot child : dataSnapshot.getChildren()) {
                      oldestPostId = child.getKey();
                      System.out.println("here si the data==&gt;&gt;" + child.getKey());
                  }      
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
  
          //////FOR THE PULL TO REFRESH CODE IS HERE
         swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
              @Override
              public void onRefresh() {
                  // Refresh items  
  
               System.out.println("Here==&gt;&gt;&gt; "+oldestPostId);
  
                  ///HERE "oldestPostId" IS THE KEY WHICH I GET THE LAST RECORDS FROM THE FIREBASE
  
                  mChatRef.startAt(oldestPostId).addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  for (DataSnapshot child : dataSnapshot.getChildren()) {
  
                      System.out.println("here AFTER data added==&gt;&gt;" + child.getKey());
                  }
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
  
              }
          });
      }
  </code></pre>
  
  <p>I have searched here on SO for it , but did not get the expected result, below link which i have searched for it<br><br>
  1. <a href="https://stackoverflow.com/q/38634300/3946958">First Link</a><br>
  2. <a href="https://stackoverflow.com/q/26386959/3946958">Second Link</a><br>
  3. <a href="https://stackoverflow.com/q/32396840/3946958">Third Link</a><br>
  4. <a href="https://stackoverflow.com/q/40360006/3946958">Forth Link</a><br></p>
  
  <p>Please look at my firebase data structure in  image.<br> <a href="https://i.stack.imgur.com/gTlVa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gTlVa.png" alt="Data of firebase"></a></p>
  
  <p>I have implemented the logic for the getting 15 OR 10 records at first time and it works..and also implemented the logic for loading more records in limits but <strong><em>not getting proper solution (NOT WORKING)</em></strong> , please help and let me know where am i doing wrong..Thanks :)</p>
  
  <h2>EDIT SOLUTION</h2>
  
  <p>:- I have implemented the load more or pull to refresh functionality on this link:- <a href="https://stackoverflow.com/questions/44777989/firebase-infinite-scroll-list-view-load-10-items-on-scrolling/44796538#44796538">Firebase infinite scroll list view Load 10 items on Scrolling</a></p>