I answered it in the other question you asked, the structure of that data is not the correct one to work with realtime, you are complicating a lot when you could structure it better.
But if you want to do it just put limitToLast (3) in the reference and get with getValue () those 3, and then you will have to use some separator that only takes the first part until dose: number
Ideally, under that push you create a map with all your values, I'll give you an example
Map<String,Object> infoDosis = new HashMap<>();
infoDosis.put("dosis",60);
infoDosis.put("Fecha",tufecha);
infoDosis.put("Hora y ubicacion",horayubicacion);
mDatabase.child("dosis").push().updateChildren(infoDosis);
That way the output in firebase is going to be the next one
dosis
|__Jks29N2PkshgXz6
| |_dosis: 60
| |_Fecha: tufecha
| |_Hora y Ubicacion: tusdatos
|
|_OtroPushKey y la misma data estructurada que arriba
.....
With that you make sure that you put under each push key 3 data, the dose, the date and the time, then with limitToLast(3)
you only bring the last 3 push keys and there if you can compare and get only doses of each one.
Doc: link