json - Get data from firebase realtime database in android -
i trying data firebase realtime database in android. have created json data file , imported json file in firebase database. data file looks :
{ "data": [ { "name" : "one", "age" : "ten" },{ "name" : "two", "age" : "twenty" } ] }
i have created pojo class. how can json objects array? i've searched while can't understand reference & child here.
i recommend changing firebase structure following:
- replace [] {} firebase recommends using practice
- add specific unique id every user(or item) have in
data
node.
take example:
as can see in picture every user has specific id. firebase provides every user unique id can string userid= user.getuid();
.
you can create unique ids aswell , them using string key = database.child("users").push().getkey();
(not advised used user ids)
if wish read data structured recommend reading this.
also read this.
wiki
Comments
Post a Comment