【发布时间】:2016-07-18 21:35:28
【问题描述】:
我无法使用 firebase 文档和 google 查找有关如何在应用启动时检索所有数据的任何信息。
假设,我想在没有任何事件的情况下获取应用启动时的所有以下数据。并存储在 ArrayList 中。假设ArrayList<Quote> 和quote 有三个字段(int id、String text、String author)。
[{
"id" : 1,
"text": "There are 1,411 tigers left in India.",
"author": "NULL"
}, {
"id" : 2,
"text": "The Greek for \"left-handed\" also means \"better\".",
"author": "NULL"
}]
根据documentation,有一个名为onDataChange()的方法,但是,应用程序不会更改任何数据。如何获取所有数据并将其存储在 ArrayList<Quote> 中,我可以将其传递给自定义适配器。
【问题讨论】:
-
从文档中读取“值事件”部分:
onDataChange() [...] This method is triggered once when the listener is attached and again every time the data, including children, changes.
标签: java android firebase firebase-realtime-database