0

my app is an agenda using Firebase(Real time Data)and Recycler View. When I choose the day from Calendar View it opens MainActivity3. In MainActivity3 I can add a new event(with time, title) and above that a Recycler view(Card view) with the information of the events. In the Recycler View I show to the date, the creator of event, title, time(I have also participants but I don't use it yet).

enter image description here

I want to show the followings in the Recycler View:

  • The events for the specific day I choose
  • The events if I am the creator(if another user login to the app and choose this date he will see only his events and not mine)

How I am going to do it? I try to use Query in Mainactivity3 for date:

Query querydate = mbase.orderByChild("date").equalTo(datequery);
       
        FirebaseRecyclerOptions<events> options = new FirebaseRecyclerOptions.Builder<events>()
                .setQuery(querydate, events.class)
                .build();

         kadapter = new kAdapter(options);
         recyclerView.setAdapter(kadapter);

This show me the right event for the date but I have to combine the creator and I have a problem.(//Query queryemail = mbase.orderByChild("email").equalTo(emailquery);)

I want 1 query with 2 properties (date, creator). How I am supposed to do that?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For example in your use-case you could have a property `"creator_date": "anastasia1@gmail,com_2022-02-22"` and order/filter on that. For a longer example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Feb 08 '22 at 20:32
  • @FrankvanPuffelen Ok thank you. But the next step of my app is to add participants. So this is a problem, I don't think that is a good idea to put all the information in a property. – anastasia papaioannou Feb 09 '22 at 13:48
  • In that case, you won't be able to filter on two values, or will have to use one of the other options in the answer I linked. – Frank van Puffelen Feb 09 '22 at 15:55

0 Answers0