Home > Mobile >  i've using startAt and endAt for getting range data, but i need to take data in another child i
i've using startAt and endAt for getting range data, but i need to take data in another child i

Time:12-07

I want to take data inside a folder of my Realtime Database that looks like this:

this is the realtime database look like

I have this code for getting the date range data and showing it in RecycleView .

    DatabaseReference db = FirebaseDatabase.getInstance ( ).getReference ( );
        DatabaseReference pendingRef = db.child ("Users").child ("Pending");

        Query queryByKey = pendingRef.orderByKey ()
                .startAt ("*"   tanggalawal)
                .endAt ("*"   tanggalakhir   "\uf8ff");

        recView = (RecyclerView)findViewById (R.id.recview);
        recView.setLayoutManager (new LinearLayoutManager (this));

        FirebaseRecyclerOptions<Model> options =
                new FirebaseRecyclerOptions.Builder<Model>()
                        .setQuery(queryByKey, Model.class)
                        .build();

        adapter = new MyAdapter (options);
        recView.setAdapter (adapter);

How can I get the DataPelanggan data inside of it?

CodePudding user response:

When you are using the Firebase-UI library for Android, it means that the adapter will be able to display only a flat list of objects based on the query that you pass in, creating one ViewHolder object for each element.

Since your actual data is located beneath nodes like DataPelanggan, KTP, and so on, that library isn't really helpful. If you can change the database schema like this:

Firebase-root
  |
  --- Pending
       |
       --- *20211127...
             |
             --- type: "DataPelanggan"            
  • Related