简体   繁体   中英

Retrieve history data from firebase realtime database

I am new to Android Development I am retrieving all Child nodes from firebase Realtime database whose appointment status is "Completed" and child has current user id but when i moved to the history it didn't show anything. Can anyone help me solve this issue.. I need the solution as soon as possible.

if (reference != null) {

            reference.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(@NonNull DataSnapshot snapshot) {

                    if (snapshot.exists()) {
                        appointmentList = new ArrayList<>();
                        for (DataSnapshot ds : snapshot.getChildren()) {
                            id = ds.getKey();
                            if (ds.child("appointmentStatus").getValue(String.class).equals("Completed")) {


                                appointmentList.add(ds.getValue(Appointment.class));

                                SalHistory history = new SalHistory(appointmentList);
                                recyclerView = findViewById(R.id.saloonHistoryRecycler);
                                recyclerView.setAdapter(history);

                            }

                        }

                    }

Firebase Database Model

在此处输入图片说明

You can use OrderbyChild to fetch items from Firebase based on appointmentStatus

reference.orderByChild("appointmentStatus").equalTo("Completed).addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(@NonNull DataSnapshot snapshot) {
   
                                }
    
                            }
    
                        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM