3
I have a database like this:
{
  "message" : "Hello, World!",
  "reserva" : [ null, {
    "codreserva" : 123,
    "email" : "[email protected]",
    "status" : "check in"
  }, {
    "codreserva" : 124,
    "email" : "[email protected]",
    "status" : "check out"
  } ]
}
And I have a code to check the status of the reservation:
public void ProcuraReserva(String codigodareserva){
// Read from the database
myRef = database.getReference("reserva/"+codigodareserva+"/status");
myRef.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        String value = dataSnapshot.getValue(String.class);
        textview1.setText("Status da reserva "+ value);
    }
    @Override
    public void onCancelled(DatabaseError error) {
        textview1.setText("Status com falha");
    }
  });
}
However, he search the ID of my reservation wanted him to search according to the CODRESERVA. Could someone help me in this matter search according to my "line" in this database of Firebase.
You didn’t bring anything by doing this.
– Fabio Nobre
I think the people did not understand given the codreserva = 123 I want to return her status.
– Fabio Nobre
Try to use the
equalTo()to compare Child’s value.mCadastroRef.orderByChild("email").equalTo(email).addListenerForSingleValueEvent(new ValueEventListener() {...mine works like this– ruitercomp