How to search data in Firebase Android

FireBase Database image

I want to find a condition, if the user says MSCS, then the search should check -> the condition that MSCS is 1, then get all the data like SJSU (University Name) and CA (City Name) on my Android application like Listview / Fragmentview.

I tried How to search for value in Android firebase , but I cannot figure it out.

+4
source share
2 answers

It sounds like you are looking for something like the following.

mDatabase.orderByChild("MSCS").equalTo(1).addListenerForSingleValueEvent(
    new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            //data will be available on dataSnapshot.getValue();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.w(TAG, "getUser:onCancelled", databaseError.toException());
        }
});

Let me know if this works for you :)

+2
source

equalTo (String value) , . SQL LIKE

+3

All Articles