I Have a long set of data on Firebase Database, and I want to create a Pagination Functionality for the App.
I've read other answers and they suggest using this method
DatabaseReference jokesRef = FirebaseDatabase.getInstance().getReference().child("child");
Query jokesQuery = jokesRef.orderByKey().startAt(offset).limitToLast(count).addValueEventListener(new OnValueEventListener() {
...
};
offset += count
But that would mean adding multi-able ValueEventListeners, one for each page.
Also, what if the pages become all loaded at once? like the user scrolls to the 10th page, that means all 10 pages stay in memory, and when the device changes orientation or any other configuration, all the pages will be gone and reloaded.