Skip to content Skip to sidebar Skip to footer

How To Get Values Of List From Firebase In Android?

I'm getting a data from Firebase as a model and in my model, there is a List so I can send it to Firebase but can't get it :( I have a model where an image is List Im

Solution 1:

there is no "document.getList("image")"

You're right, there is no getList() method in the QueryDocumentSnapshot class but because it extends DocumentSnapshot class, you can use get(String field) method:

Returns the value at the field or null if the field doesn't exist.

So if your image property is of type array, you can simply get it as List using the following line of code:

List<String> vehicleList = (List<String>) document.get("image");

Now you can create an object of Vehicle class by passing vehicleList to the constructor.

Post a Comment for "How To Get Values Of List From Firebase In Android?"