Firebase RealTime Database querying with multiple selected field values in Android not working

Trying to query the data from RealTime Database based on selected values, but multiple inputs as Arraylist are not working in a single query.

 private void readUsers()
    {
     
     DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
     reference.getRoot().equals(query);
        
   Query query12 = reference.child("Users").equals("[email protected]");//**how to add multiple email id or as array list**
    query12.addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    if (dataSnapshot.exists()) 
    {
                      
                        for (DataSnapshot issue : dataSnapshot.getChildren())
                        {
                           

                        }
    
                    }
                }
    
                @Override
                public void onCancelled(DatabaseError databaseError) {
    
                }
            });
    
        }

Kindly help me.

Answer

You cannot add multiple conditions to the following query:

Query query12 = reference.child("Users").equals("[email protected]");

The orderBy() and equalTo() methods can be used in a query only once. You can use a range, or why not, Cloud Firestore as explained in my answer from the following post:

Leave a Reply

Your email address will not be published. Required fields are marked *