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 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:
DatabaseReference root = 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
DatabaseReference root = database.getReference().child("Eventos");
Query query = root.orderByChild("participantes/id_Usuario").equalTo(2);