Reputation: 2204
I am learning android and I want to show the values from firebase Db into a recyclerview in my app.
I have a pojo class like,
And I got the iteration value from firebase like shown in below picture.
You can see that each entity of my model class is coming as a Hashmap key.
How should i iterate through this, so that i can pass the values to my model class constructor and thereby add the model class to my recyclerview adapter list.
. . . .
Upvotes: 0
Views: 762
Reputation: 103254
You need a so-called 'marshalling' library which turns JSON into java POJOs.
The commonly used libraries are jackson and GSON ... for normal java. For android? Possibly something is baked in. Perhaps GSON, which is authored by google.
Upvotes: 2
Reputation: 6239
If your HashMap is always with the size of 3 and you know the key names, then you can just do the following.
UserInfo info = new UserInfo(map.get("referralName"), map.get("referralContact"), map.get("referralType"));
Upvotes: 2