java - How to retrieve the latest data that has been pushed to a child in Firebase? -


so still trying app , have run brick wall, retrieve latest "bloodlevel" set of data has been saved firebase , output textview , im not sure how that:

"bgratio" : "1",   "carbratio" : "5",   "entries" : {     "-kfcv3kfcmtcbesa9wv6" : {       "bloodlevels" : "7.5",       "carbohydrates" : "20",       "dateandtime" : "19 mar 2017, 21:36:47",       "insulin" : "4.5"     },     "-kfcx05fo2xdylakrbw-" : {       "bloodlevels" : "14",       "carbohydrates" : "65",       "dateandtime" : "19 mar 2017, 21:45:17",       "insulin" : "20.0"     },     "-kfcrf6dksolrl36dn4u" : {       "bloodlevels" : "12",       "carbohydrates" : "90",       "dateandtime" : "19 mar 2017, 23:18:03",       "insulin" : "23.0"     },     "-kfeqt1t27rksnmkzrya" : {       "bloodlevels" : "24",       "carbohydrates" : "10000",       "dateandtime" : "20 mar 2017, 08:35:43",       "insulin" : "2017.0"     },     "-kg4du0em8sx9uihbdl4" : {       "bloodlevels" : "13.3",       "carbohydrates" : "50",       "dateandtime" : "mar 25, 2017, 11:28:54 am",       "insulin" : "16.3"     },     "-kgixnjnsdptakpo62hn" : {       "bloodlevels" : "8.0",       "carbohydrates" : "40",       "dateandtime" : "mar 28, 2017, 9:08:30 am",       "insulin" : "9.0"     },     "-kgoj-4egu5z_dtuxfoq" : {       "bloodlevels" : "10",       "carbohydrates" : "50",       "dateandtime" : "mar 29, 2017, 10:05:25 am",       "insulin" : "13.0"     }   },   "ideal level" : "7" } 

any on great, thank you!!!

you should saving dateandtime timestamp can orderbychild('dateandtime') on , select last 1 using limittolast(1).

https://firebase.google.com/docs/reference/android/com/google/firebase/database/query.html#orderbychild(java.lang.string) https://firebase.google.com/docs/reference/android/com/google/firebase/database/query#limittolast(int)


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -