final DatabaseReference reference=FirebaseDatabase.getInstance().getReference("Client");
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
for (DataSnapshot snapshot1:snapshot.child("c_orders").getChildren()){
final String rt=snapshot1.getKey().toString();
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
FirebaseRecyclerOptions<client_model_btncheckorders> options2 =
new FirebaseRecyclerOptions.Builder<client_model_btncheckorders>()
.setQuery(FirebaseDatabase.getInstance().getReference().child("Client").child("c_orders").child(rt).child("check_orders"), client_model_btncheckorders.class)
.build();
adapter2=new adapter_clientside_checkbtn(options2);
recyclerView2.setAdapter(adapter2);
return view;
}
Here I have to retrieve the value of "rt" which is in for loop and that is to be then passed to a Firebase database query to retrieve the child element's value. But the problem is, "rt" may contain many usernames of the firebase real-time database. I have to split them and refer a each username to the query. It is not possible to write Firebase reference inside for loop because the adapter of the recycler view(where data needs to be displayed) cannot be accessed. The recycler view where I was trying to display data from firebase database displays by pressing a button of another recycler view. Is there any solution for this?