After the user has made an appointment, the attribute(user id, date, time) is stored in the appointment table with the therapist push id as the parent node(to facilitate the retrieval of certain doctor's appointment).
Now, in the user interface, I need to get all the attribute by using the user id. Does anyone know how to do it?
Here is my database structure
Here is my own code
a=new ArrayList<AppointmentObject>();
databaseReference= FirebaseDatabase.getInstance().getReference();
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
//to get current log in user id
String userid1 = FirebaseAuth.getInstance().getCurrentUser().getUid();
for(DataSnapshot dataSnapshot1: dataSnapshot.child("appointment").getChildren()) {
//if the userid stored is same as user id, it will be added to arraylist
if(dataSnapshot1.getValue(AppointmentObject.class).getUserid().equals(userid1)){
AppointmentObject thera= dataSnapshot1.getValue(AppointmentObject.class);
a.add(thera);
}
}
adapter=new MyRecyclerviewPAppointment(MainActivityPAppointment.this, a);
rv.setAdapter(adapter);
}
However, it appears this error