-1

I want to retrieve data from a child "Orders" but data is stored under a number then data is stored under a key which is generated in another application but I can't find a way

this is the code of recycle view where data is being retrieved

recyclerVieww.setLayoutManager(new LinearLayoutManager(this));
    FirebaseRecyclerOptions<historyModel> options =
            new FirebaseRecyclerOptions.Builder<historyModel>()
                    .setQuery(FirebaseDatabase.getInstance().getReference().child("OrdersAdimin")
                            , historyModel.class)
                    .build();

    catAdapt = new historyAdapter(options);
    recyclerVieww.setAdapter(catAdapt);

this is the JSON file:

"Orders": {
"12": {
  "-NV3N3KYwcjXo5hfZ6h1": {
    "BuyerPhoen": "12",
    "PickUP": "Of-16",
    "date": "May 10, 2023",
    "orderId": "-NV3N3KYwcjXo5hfZ6h1",
    "productName": "Sprite(250ml)",
    "productPrice": "₹25",
    "quantity": "1",
    "time": "12:06:37 PM",
    "totalPrice": 25
  }
}
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • I'm having a hard time understanding what the problem is. What exactly in this code doesn't work the way you expect? Tell us what is wrong with shared code. Do you have any errors? – Alex Mamo May 13 '23 at 05:49
  • @AlexMamo I want to retrieve data from the key but I can't get into the key – Aditya Singh Rajput May 13 '23 at 08:13

1 Answers1

0

According to your last comment:

I want to retrieve data from the key but I can't get into the key.

This is most likely because of the following line of code:

.setQuery(FirebaseDatabase.getInstance().getReference().child("OrdersAdimin")

Your node name is Orders and not OrdersAdimin. So please change the above line into:

.setQuery(FirebaseDatabase.getInstance().getReference().child("Orders")
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193