我正在尝试使用以下代码获取客户数据,它总是返回null

时间:2019-11-20 17:12:49

标签: java android firebase-realtime-database

firebaseDatabase = FirebaseDatabase.getInstance();
assert post_id != null;
DatabaseReference database = firebaseDatabase.getReference().child("RegisteredTrips").child(post_id).child("Customer");
database.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
        ArrayList data = new ArrayList<>();
        for (DataSnapshot noteDataSnapshot : dataSnapshot.getChildren()) {
            assert noteDataSnapshot != null;
            Customer value = noteDataSnapshot.getValue(Customer.class);
            data.add(value);


        }
        mListadapter = new ListAdapter(data);
        mRecyclerView.setAdapter(mListadapter);
    }

    @Override
    public void onCancelled(@NonNull DatabaseError databaseError) {

    }
});

this is my firebase data tree

0 个答案:

没有答案