Have a problem when getting the children count for my firebase database reference.
I am using a
private long childs;
this variable gets set in onCreate like this:
ref_1 = new Firebase("https://xxxxxxxxxx-xxxxx.xxxxxxxxx.com/traning/crossfit/level"+condition);
ref_1.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
childs = dataSnapshot.getChildrenCount();
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
If i debug this code at the dataSnapshot it have counted the children and its correct, but when using this global variable childs on other places in the file there is somehow set to zero.