solved
Android - Firebase - Getting Child of Child Data
how to view leaf nodes both children and grandchildren
E/data: {6640={first={sub3=dbms, m5=3, m2=2, sub2=dl, sub1=cis, m3=2, sub4=socio, m4=2, sub5=english, m1=4}}}
the values i want are
- the children inside 6640 eg : first and second
- the grandchildren inside first eg : sub1--sub5 and m1-m5
the data above is a snapshot data snapshot from a query.. how do i access each values from the following snapshot.. i created a data module and used a for each loop like this
for (DataSnapshot post : dataSnapshot.getChildren())
{
trial_module m2 = post.getValue(trial_module.class);
Log.e("data",dataSnapshot.getValue().toString());
data2.add(m2);
}
do i need to create mutiple classes to hold data?
public class Result_module {
String sub1,sub2,sub3,sub4,sub5;
long m1,m2,m3,m4,m5;
public String getSub1() {
return sub1;
}
public void setSub1(String sub1) {
this.sub1 = sub1;
}
public String getSub2() {
return sub2;
}
public void setSub2(String sub2) {
this.sub2 = sub2;
}
public String getSub3() {
return sub3;
}
public void setSub3(String sub3) {
this.sub3 = sub3;
}
public String getSub4() {
return sub4;
}
public void setSub4(String sub4) {
this.sub4 = sub4;
}
public String getSub5() {
return sub5;
}
public void setSub5(String sub5) {
this.sub5 = sub5;
}
public long getM1() {
return m1;
}
public void setM1(long m1) {
this.m1 = m1;
}
public long getM2() {
return m2;
}
public void setM2(long m2) {
this.m2 = m2;
}
public long getM3() {
return m3;
}
public void setM3(long m3) {
this.m3 = m3;
}
public long getM4() {
return m4;
}
public void setM4(long m4) {
this.m4 = m4;
}
public long getM5() {
return m5;
}
public void setM5(long m5) {
this.m5 = m5;
}
}