user2536273
user2536273

Reputation: 69

How to Search for data in Firebase Android

FireBase Database image

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

I tried How to search for a value in firebase Android but I'm unable to figure it out.

Upvotes: 4

Views: 6927

Answers (2)

user963012
user963012

Reputation:

Firebase equalTo(String value) method only returns value if it matches exactly. It is not like SQL LIKE query

Upvotes: 3

adolfosrs
adolfosrs

Reputation: 9389

Sounds that 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 :)

Upvotes: 3

Related Questions