This is my database structure. I am trying to fetch Order Details.
Here is the code
databaseReference = FirebaseDatabase.getI
The problem is you are trying to convert a string ( the values in OrderDetails
) to OrderDetails
object
Solution:
databaseReference = FirebaseDatabase.getInstance().getReference().child("Admin Order").
child(userID);
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot childSnapshot : dataSnapshot.getChildren()) {
OrderDetails orderDetails = childSnapshot.child("Order Details").getValue(OrderDetails.class);
Log.w("orderDetails", orderDetails.getConsumer());
mList.add(details);
progressBar.setVisibility(View.INVISIBLE);
}
adapter = new PreviousOrderAdapter(getContext(), mList);
recyclerView.setAdapter(adapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
progressBar.setVisibility(View.INVISIBLE);
}
});