0

I have not found any solution when I am loading data from firebase database

DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("videodata");
        databaseReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for(DataSnapshot ds : dataSnapshot.getChildren()){
                    RecData listdata = new RecData();
                    listdata.setCategory(ds.child("name").getValue(String.class));
                    listdata.setEmail(ds.child("Email").getValue(String.class));


                    dataload.add(listdata);
                }
                layoutmanager = new LinearLayoutManager(MainActivity.this);
                recyclerView.setLayoutManager(layoutmanager);
                adapter = new RecyclerViewAdapter(dataload);
                recyclerView.setAdapter(adapter);

            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });

but how can I add pagination because from firebase it fetched full data. Please give a solution without using query and all

KENdi
  • 7,576
  • 2
  • 16
  • 31
  • If you consider at some point to try using [Cloud Firestore](https://firebase.google.com/docs/firestore/), you can try **[this](https://stackoverflow.com/questions/50741958/how-to-paginate-firestore-with-android)**. – Alex Mamo Mar 05 '19 at 13:26
  • There is no way to implement pagination without using a query. At the very least you'll need `limitToFirst` for the first page, and `startAt()` for subsequent pages. Aside from that there are dozens of [questions that deal with pagination on Firebase](https://stackoverflow.com/search?q=%5Bfirebase-realtime-database%5D%5Bandroid%5D+pagination). Unless you've tried something already and are stuck on a more specific part of the problem that is different from those questions, I consider this question too broad. – Frank van Puffelen Mar 05 '19 at 14:39
  • Some offsite tutorials: https://howtofirebase.com/firebase-data-structures-pagination-96c16ffdb5ca, https://www.youtube.com/watch?v=CH9ptm4NeTw, https://www.youtube.com/watch?v=TIGj7KzXtxg, https://jsfiddle.net/katowulf/s74y3cy5/ and https://angularfirebase.com/lessons/simple-firebase-pagination-with-angularfire2/ – Frank van Puffelen Mar 05 '19 at 14:41
  • Not understand with your answer because i have not worked on a Query before with firebase so how can i add Query in the above given code. can you please help me with the editing my code with query and scrollbarlistener. –  Mar 06 '19 at 12:35

0 Answers0