下面有一段代码。我不知道为什么无法触发onDataChange。因此,对象singleChildSummary为null。
>ChildSummary singleChildSummary;
>DatabaseReference childSummaryRef = getChildDatabaseReference().child(id);
> childSummaryRef.addListenerForSingleValueEvent(new ValueEventListener() {
> @Override
> public void onDataChange(DataSnapshot dataSnapshot) {
> singleChildSummary = dataSnapshot.getValue(ChildSummary.class);
> }
>
> @Override
> public void onCancelled(DatabaseError error) {
> // Failed to read value
> // Log.w(TAG, "Failed to read value.", error.toException());
> }
> });