[英]How to retrieve list of different object types from Firebase?
I'm facing a problem that I have a list of different object types and I'm fetching that list using AddClildEventLitener(), so the problem is to retrieve those objects I should give specific object to "getValue(SpecificObject.class)".我面临一个问题,我有一个不同对象类型的列表,我正在使用 AddClildEventLitener() 获取该列表,所以问题是检索那些我应该将特定对象提供给“getValue(SpecificObject.class)”的对象。
So, How can I achieve this step?那么,我怎样才能实现这一步呢?
Example of realtime DB structure:实时数据库结构示例:
-List
-random id1(Object)
-title
-description
-random id2(Object)
-first name
-last name
-random id3(Object)
-title
-image
-random id4(Object)
-title
-description
-image
I'm pretty sure I've answered this not too long ago, but I'll try again.我很确定我不久前已经回答了这个问题,但我会再试一次。
The getValue(SpecificObject.class)
method maps the properties from the DataSnapshot
to an instance of the SpecificObject
class. getValue(SpecificObject.class)
方法将DataSnapshot
的属性映射到SpecificObject
类的实例。
If you have multiple different object types in your database, you will:如果您的数据库中有多个不同的对象类型,您将:
getValue(...)
with the correct class for that type.getValue(...)
。 Also see:另见:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.