Android - How to retrieve list of objects in their insertion order from Firebase?

后端 未结 4 435
别跟我提以往
别跟我提以往 2021-01-14 11:47

What do I want?

I want to retrieve the list of objects in their insertion order from Firebase Database.

How am I adding the object

4条回答
  •  情话喂你
    2021-01-14 12:40

    If you are having HashMap inside class and want to get whole firebase object using getValue(Classname.class)

    Method bellow will help you

    get it into TreeMap from HashMap and you'll have ordered list as in firebase by key

    Example code

    TreeMap recordingsTreeMap = new TreeMap<>();
    recordingsTreeMap.putAll(project.getRecordings());
    

    You will have ordered list by key in TreeMap object.

    where project is a class having multiple fields and one or more HashMap and you don't want to query each separately.

提交回复
热议问题