Firebase Query don't show all the data

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Firebase Query don't show all the data



I need to get all users of a determined age range, but my code does not work.



My Firebase database structure is this.


-user
-1
-name:"James"
-age:"21"

-2
-name:"Artur"
-age:"25"

-3
-name:"Charlotte"
-age:"25"

-3
-name:"Marvin"
-age:"80"



My code is this. With this I just catch 1 user.


DatabaseReference uRef = database.getReference("users");

Query UserQuery = uRef.orderByChild("age").startAt(21).endAt(50);

UserQuery.limitToFirst(10).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {

int counter =(int) dataSnapshot.getChildrenCount();

Log.d("TAG////////", String.valueOf(counter));




}


@Override
public void onCancelled(DatabaseError databaseError) {

}
});



But if I delete the endAt() condition, I catch all users after 21 and I just wanna catch the users in the range.


DatabaseReference uRef = database.getReference("users");

Query UserQuery = uRef.orderByChild("age").startAt(21); //I deleted endAt(50);

UserQuery.limitToFirst(10).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {

int counter =(int) dataSnapshot.getChildrenCount();

Log.d("TAG////////", String.valueOf(counter));




}


@Override
public void onCancelled(DatabaseError databaseError) {

}
});



Please help me.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

b0J3lzW6kYp ESzcAnWHCfj4O7IkNXDBN,F1f7u7 NV,lJ91Rk,XDldIOVKXgvgcORvEyx5exI7nCQ q0t2eDyj
9IMU,yLlmecmUgc,Pyo,aYgmo2wmno9ckwHDPysbCd 8fov9e5O3Q2 a,CIO

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results