java - 如何通过索引获取 Firebase 的值?
问题描述
我正在尝试根据位置从 Firebase 检索数据。如果我不知道第一个值的键是什么样的,我如何访问第一个位置的值?
ticketCodes.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
GenericTypeIndicator<List<String>> t = new GenericTypeIndicator<List<String>>() {};
List<String> yourStringArray = dataSnapshot.getValue(t);
// Here I want to receive the value of the first index in firebase without knowing what the key is.
//I am not able to. Though if I put "get(firstKey)" it gives me the value of the first index.
String value = yourStringArray.get(0);
是否有另一种方法可以访问此列表中的第一个位置?我的数据库如下所示:
解决方案
推荐阅读
- php - 遍历数组
- c++ - 警告 C6387 Visual Studio
- python - 我可以从字符串的每一行中仅提取整数并将它们保存在列表中吗?
- android - 构建 Kotlin 类以使用 Gson 将 json 响应转换为类
- iframe - 为什么 iFrame 用于静默身份验证?
- php - 按库存和价格对产品进行排序 woocommerce
- twilio - 在继续执行 twilio 无服务器函数中的下一行代码之前,如何让我的 for await 循环在其主体内执行所有操作?
- typescript - 使用纱线工作区时,tsc 在 apollo-server 中找不到 express 的声明文件
- google-sheets - 计算范围单词出现在单元格中的次数(谷歌表格)
- javascript - 使用 JavaScript 对 Firebase 数据库中的电子邮件 ID 进行重复检查