简体   繁体   English

从android studio中的firebase获取特定数据

[英]Fetching specific data from firebase in android studio

Trying to fetch related data from firebase 试图从firebase获取相关数据

I am new in Android and I am stuck here, want to retrieve data from Firebase where "del_id = 1" and "date = 2019-3-18" but I don't know how to write as Firebase way to retrieve what I want, Image above will further demonstrate what I have tried and what I want. 我是Android的新手,我被困在这里,想要从Firebase中检索“del_id = 1”和“date = 2019-3-18”的数据,但我不知道怎么写Firebase的方式来检索我想要的东西,上面的图片将进一步展示我尝试过的和我想要的东西。

Your answer will be highly valuable for me. 你的答案对我来说非常有价值。

The following line of code: 以下代码行:

invSnapsjot.getValue(Invoice.class)

Returns an object of type Invoice and not a DataSnapshot object so you can call .child() method on it. 返回Invoice类型的对象而不是 DataSnapshot对象,因此您可以在其上调用.child()方法。

If you want to get a specific element (del_id = 1) , you should simply use a query that looks like this: 如果要获取特定元素(del_id = 1) ,您应该只使用如下所示的查询:

myDatabase.orderByChild("del_id").equalTo("1").addValueEventListener(/* ... */);

Unfortunately, Firebase realtime database does not support queries on multiple properties but there is still a workaround for that, so please see my answer from the following post: 不幸的是,Firebase实时数据库不支持多个属性的查询,但仍然有一个解决方法,所以请从以下帖子看到我的答案:

If you want to write or update value at that time you need to take .addValueEventListener 如果要在此时写入或更新值,则需要使用.addValueEventListener

If you want to only set your value in firebase you directly set value without using .addValueEventListener 如果你想只设置在火力你的价值 ,你直接设置值,而无需使用.addValueEventListener

More details refer this link https://firebase.google.com/docs/database/android/read-and-write 更多详细信息,请参阅此链接https://firebase.google.com/docs/database/android/read-and-write

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 android studio 中的 recyclerview 适配器从 firebase 获取特定密钥 - Fetching specific key from firebase using recyclerview adapter in android studio 从 Firebase 在 Android 中获取数据时出错 - Error while Fetching Data in Android from Firebase Android Studio:如何从 Firebase 检索特定数据? - Android studio : How do I retrieve specific data from Firebase? 我正在从 firebase Realtime Db 获取数据,并在 recyclerview 问题上获取数据是 Collection.shuffling 在 android studio 中重复相同的项目 - I am getting data from firebase Realtime Db and fetching on recyclerview issue is Collection.shuffling is repeating same item in android studio 从firebase获取数据,在android中执行后屏幕显示空白 - Fetching data from firebase, Screen shows blank after executing in android 从Firebase数据库中获取数据 - Fetching data from firebase database 在Android Studio中从SQlite提取数据时出错 - Error while fetching data from SQlite in Android Studio retrofit 从 android 工作室的本地存储中获取数据 - retrofit fetching data from local storage in android studio Firebase 未从 Android Studio 接收数据 - Firebase is not receiving data from Android Studio 如何使用 Android Studio 从 Firebase 实时数据库中的节点检索特定数据? - How to retrieve a specific data from a node in Firebase Realtime Database using Android Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM