I have read many answers to this question, none solved my problem.
ValueEventListener dataListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds : dataSnapshot.getChildren()) {
DataSnapshot ls = ds.child("/leafBox001");
DataSnapshot cs = ls.child("/currentState");
Log.i(TAG, "msg " + cs + ls + ds);
}
Log returns the following:
DataSnapshot { key = leafBox001, value = {lightSensor=6793, currentState=false} }
DataSnapshot { key = currentState, value = null }
DataSnapshot { key = leafBox001, value = null }
As you can see, when I try to access a child the values become null.
I also always get null when using getValue. Example of that code:
ValueEventListener dataListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds : dataSnapshot.getChildren()) {
currentState = ds.child("/leafBox001").child("/currentState").getValue(Boolean.class);
Log.i(TAG, "msg " + cs + ls + ds);
}
I have tried every variation of the above code, always null.
RTD Structure