FirebaseUser fUser = FirebaseAuth.getInstance().getCurrentUser();
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("Users");
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
usersList.clear();
for (DataSnapshot ds: snapshot.getChildren()){
ModelUsers modelUsers = ds.getValue(ModelUsers.class);
if (!modelUsers.getyearSection().equals(fUser.getUid())){
usersList.add(modelUsers);
}
adapterUsers = new AdapterUsers(getActivity(), usersList);
recyclerView.setAdapter(adapterUsers);
}
}
This is my Firebase Database Users
{
"Users": {
"7xWet0t6jZYcajSpt70nqbQy29q1": {
"Password": "randomber16",
"email": "klmartisano@gmail.com",
"fullName": "Kenneth L. Martisano",
"uid": "7xWet0t6jZYcajSpt70nqbQy29q1",
"usertype": "Student",
"week5score": "4",
"yearSection": "4-2"
},
"aMx87W9b0vaQTwocAqKzuEvGj0G3": {
"Password": "randomber16",
"email": "srosarda@gmail.com",
"fullName": "Sean Harvey C. Rosarda",
"uid": "aMx87W9b0vaQTwocAqKzuEvGj0G3",
"usertype": "Instructor",
"yearSection": "4-2"
},
"q78J0so5mgdIBlTfMRSxWqXuxPj1": {
"Password": "randomber16",
"email": "cambroneroanne09@gmail.com",
"fullName": "Anne Cambronero",
"uid": "q78J0so5mgdIBlTfMRSxWqXuxPj1",
"usertype": "Student",
"yearSection": "4-2"
}
},
im new to android studio and im asking if there's a way to this to diplay users info using child value "yearSection" and current user "yearSection"
Im trying to call users in firebase database using child value of "yearSection" and display users with specific yearSection that equals to the current users "yearSection"