Friends I'm doing a project in Firebase database with android and I need to consult and get the last three values saved with the name of "dose" this is the structure in Firebase
This is my user.java class
public class usuario {
private String email;
private String dosis;
private String id;
private int dia;
private int mes;
private int año;
public usuario(String email, String dosis, String id, int dia, int mes, int año) {
this.email = email;
this.dosis = dosis;
this.id = id;
this.dia = dia;
this.mes = mes;
this.año = año;
}
public usuario() {
}
public int getDia() {
return dia;
}
public void setDia(int dia) {
............
This is how I'm getting the value in an activity and inside a button I have
my.orderByChild("usuario").limitToLast(3).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
usuario us =dataSnapshot.getValue(usuario.class);
textViewcalculo.setText(us.getDosis());
}
but in the debug I get this by pressing the button on which I'm making the call.
Someone who can tell me if it is the right way or if there is another and what would it be? Thanks.