Skip to content

Instantly share code, notes, and snippets.

@jerryOkafor
Last active November 12, 2016 15:17
Show Gist options
  • Save jerryOkafor/342b02dd0813a91313f166a09f451289 to your computer and use it in GitHub Desktop.
Save jerryOkafor/342b02dd0813a91313f166a09f451289 to your computer and use it in GitHub Desktop.
public static class QuerySetByMembers{
public void querySet(String memberId)
{
Query queryByMember = FirebaseDatabase.getInstance().getReference().child("sets").orderByChild("members/"+memberId);
queryByMember.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Not that we are returning a list as our query is on sets
//so iterate through the datasnapshot and get the values
for (DataSnapshot data : dataSnapshot.getChildren())
{
Set set = data.getValue(Set.class);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
//handle some errors here
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment