Get Map value from Firebase java

Viewed 752

I would like to as you with support.

In Firebase I have document with this hierarchy:

Firebase hierarchy: Firebase hierarchy

In Firebasehandler.java I receive the data from :

for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {

   String title = DocumentSnapshot.get(ARG_Firebase_Offer_Title).toString();
   Timestamp dateStartCruise = documentSnapshot.getTimestamp(ARG_Firebase_Offer_DateStartCruise);
   Long numberOfCrew = documentSnapshot.getLong(ARG_Firebase_Offer_MaxNumberCrew);
}

It is working for Long, String and others. Unfortunately I don't know how to receive data from Firebase in format Map.

Thank you very much all for support.

1 Answers

DocumentSnapshot's get() method will return a Map<String, Object> when the document field is an object. Simply cast it to that type.

Related