使用Android获取Firebase Realtime数据库中最后一个节点的数组元素 [英] Get the array elements of the last node in Firebase Realtime Database with Android
本文介绍了使用Android获取Firebase Realtime数据库中最后一个节点的数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如下图所示,我有一个名为"fridge
"的数据库表",它有一个名为"food
"的子级. food
是一个可以包含一个或多个元素的数组.
我想访问最后一个节点并获取食物元素并将其添加到列表中,但是我不知道该怎么做.
As shown in the image below, I have a database "table" called fridge
that has a child called food
. food
is an array that can contain one or more elements.
I want to access the last node and fetch the food elements and add them in a list, but I couldn't figure out how to do it.
谢谢您的帮助
推荐答案
You could follow the docs and use the limitToLast() method. Keys in firebase are ordered alphabetically.
这篇关于使用Android获取Firebase Realtime数据库中最后一个节点的数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文