I used a query that take a specific date from the user to get data from the database but it keep saying that the data is noted existing even if I used two-loop one over the Uid and one over push key. here is the code I write.
final DatePickerDialog datePickerDialog = new DatePickerDialog(AdminAppointmentManage.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
month += 1;
selectedDate = dayOfMonth + "/" + month + "/" + year;
dateText.setText(selectedDate);
Query query = FirebaseDatabase.getInstance().getReference().child("Appointment").orderByChild("dateOfAppointment").equalTo(selectedDate);
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
appointmentList.clear();
List<String> appointmentKey = new ArrayList<>();
if (dataSnapshot.exists()) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
for (DataSnapshot appointmentSnapshot : snapshot.getChildren()){
appointmentKey.add(appointmentSnapshot.getKey());
Appointments appointments = appointmentSnapshot.getValue(Appointments.class);
appointmentList.add(appointments);
}}
adapter.notifyDataSetChanged();
} else {
Toast.makeText(AdminAppointmentManage.this, "No Appointment for that day !!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}, year, month, day);
the database tree :