Query Nested Data From Firebase Real-time Database Android
I have the structure in the image below and I want to get the whole data from the node 'aaa1234' querying by 'id_Usuario'. How can I do that query? I tried: DatabaseReference root
Solution 1:
I see two mistakes.
The first one is a typo, which I already marked in my comment. You're storing the user ID as a number, so shouldn't have quotes around the value in equalTo. So: .equalTo(2)
The second mistake is in the way you try to query:
DatabaseReferenceroot= database.getReference().child("Eventos").child("participantes");
This will create a reference to the non-existing child Eventos/participantes
. What you want to do instead is query Eventos
, but then against property participantes/id_Usuario
. So
DatabaseReferenceroot= database.getReference().child("Eventos");
Queryquery= root.orderByChild("participantes/id_Usuario").equalTo(2);
Post a Comment for "Query Nested Data From Firebase Real-time Database Android"