title: Firebase android pagination
body: <p>I'm building an app which will show videos stored on firebase. The list of videos needs to be paginated fetching most recent 20 videos at a time. </p>
  
  <p><a href="https://i.stack.imgur.com/NnQzZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NnQzZ.png" alt="enter image description here"></a></p>
  
  <p>Here is the code I thought would work </p>
  
  <pre><code>  private void getVideos() {
  
          Query videosQuery = FirebaseUtil.getVideosRef();
          videosQuery.startAt(0);
          videosQuery.endAt(1);
  
          ChildEventListener videosChildEventListener = new ChildEventListener() {
              @Override
              public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                  String date = dataSnapshot.getKey();
                  String temp = date;
              }
  
              @Override
              public void onChildChanged(DataSnapshot dataSnapshot, String s) {
  
              }
  
              @Override
              public void onChildRemoved(DataSnapshot dataSnapshot) {
  
              }
  
              @Override
              public void onChildMoved(DataSnapshot dataSnapshot, String s) {
  
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
                  Log.d(tag, "database error");
              }
          };
  
  
          ValueEventListener videoValueEventListener = new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  String date = dataSnapshot.getKey();
                  String temp = date;
  
                 long count =  dataSnapshot.getChildrenCount();
                  String value = dataSnapshot.getValue().toString();
                  temp = value;
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  Log.d(tag, "database error");
              }
          };
  //        videosQuery.addChildEventListener(videosChildEventListener);
          videosQuery.addValueEventListener(videoValueEventListener);
  
      }
  </code></pre>
  
  <p>But above code retrieves entire list of videos instead of limited videos. How can pagination be implemented.</p>