title: firebase android pagination with recyclerview
body: <p>Hey I'm developing an app which will show latest data which I add on firebase database on daily basis. Most recent data should appear on top in recyclerview. Here is how the the nodes look like on firebase</p>
  
  <p><a href="https://i.stack.imgur.com/6Zitr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6Zitr.png" alt="enter image description here"></a></p>
  
  <p>Lets assume that currently there are 100 nodes in the database. When the app opens it gets the data stores in nodes 100 to 80. When the user scrolls down it gets more latest data stored in node 79 to 59 and so on.</p>
  
  <p>Right now I'm able to get the last 20 nodes with this query</p>
  
  <pre><code>   Query jokesQuery = FirebaseDatabase.getInstance().getReference().child("hindi-jokes").orderByKey().limitToLast(20);
  </code></pre>
  
  <p>I can get the key of the node at position 79 if I modify the query to limit to last 21 items but how do I then use the 79th nodes key to get the next set of node data i.e from 79th to 59th ? </p>