android - How can I retrieve the values of parent as well as child using the same getValue(user.class) method from firebase? -
i want retrieve data parent child node @ same time in model class. example:
students: { student1: { id: 1, name: "sam", regno: "15001" 1stsmester: { c: 70, datastructures:80, }, 2ndsemester: { cplus:85, sql:68 } } student2: { id:2, name:"rob", regno:"15002" 1stsemester: { c:59, datastructures:77 }, 2ndsemester: { cplus:60, sql: 85 } }
so, question how retrieve data student1 , student2? so, parents values 1stsemester , 2ndsemester child values 2 separate objects , map own model class.
thank in advance help.
make student , semester class
class students { int id; string name, regno; semester semester1, semester2; public semester getsemester1() { return semester1; } ... } class semester { string coursename; double result; }
update
inner class has declared outside , setters , getters have set inner class objects.
call data
firebasedatabase.getinstance().getreference().child("students") .addvalueeventlistener(new valueeventlistener(){ @override public void ondatachange(datasnapshot datasnapshot){ if(datasnapshot.exists()){ arraylist<student> allstudents= (arraylist<student>)datasnapshot.getvalue(); } @override public void oncancelled(databaseerror databaseerror){ } }); }
Comments
Post a Comment