How can I get my firebase records from 10 to 10? [closed]

0

I have my database in firebase and I want you to return the data of 10 in 10 every time you press a button. How can I do this?? I am programming in android studio and I am new in this of firebase Thank you very much ...

This is what I'm doing but it does not return any data

    
asked by Marco 19.07.2017 в 17:53
source

1 answer

4

What you are trying to do is called page. Try the following

mOffset = 0;
mPageSize = 10;

mOffset += mPageSize;

mQuery = mDatabase.child("TU_PATH_FIREBASE")
   .limitToFirst(mPageSize)
   .startAt(mOffset);

In summary, mPageSize indicate how many items you want to read (field limitToFirst )

The mOffset helps you to know how many items you have already read. When it is your first reading, mOffset is 0 and you will read from 0 to 9, and in your second reading, you must increase that value to 10 (page size) so that it reads from 10 to 19 and so on

    
answered by 19.07.2017 в 18:08