I have the structure corresponding to the data stored in Firebase Database via android
I want to obtain the data indicated in red the last 2 or 3 "doses" saved.
I have this structure but I do not know if it is the correct one to obtain the data and compare which one was the largest using if () {} and show the result on the screen.
my.child("usuario").orderByKey().limitToLast(3).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot snapshot : dataSnapshot.getChildren()) {
usuario us =snapshot.getValue(usuario.class);
//textViewcalculo.setText(us.getDosis());
Log.e("Datos: " , "" + us.getDosis());
}
}
The code frangment extracts the information but I do not know how to identify it and obtain it to compare
the debug shows the last three, but it does not help me to compare them so someone knows how I can do it ?? thanks