Hi everyone, I am using firebase base in my application. I can add data to the database. Now I want to implement a search in my application, I have two options for search users,
1) Blood type
2) User area
I can get blood type data, but I donβt know how I can get blood type and region data. (Filter with multiple filters)
Now, if the user selects 'A +' as the blood type from the counter and select Area 'ABC', then the result will look like users with the blood type βA +β and βABCβ.
search_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("Default Selected"+sel_blood_group); mFirebaseDatabase.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { //Your Logic here for (DataSnapshot eventSnapshot : dataSnapshot.getChildren()) { UserRegisterModel mModel = eventSnapshot.getValue(UserRegisterModel.class); // Log.e("DATA" ,""+ mModel.getName()); } Query chatRoomsQuery = mFirebaseDatabase.orderByChild("blood_group").equalTo(sel_blood_group); chatRoomsQuery.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.exists()) { // dataSnapshot is the "issue" node with all children with id 0 for (DataSnapshot issue : dataSnapshot.getChildren()) { // do something with the individual "issues" UserRegisterModel mModel = issue.getValue(UserRegisterModel.class); Log.e("QUERY DATA" ,""+ mModel.getName()); } } } @Override public void onCancelled(DatabaseError databaseError) { } }); Log.e("DATA" ,""+ chatRoomsQuery.toString()); } @Override public void onCancelled(DatabaseError databaseError) { } }); } });
android firebase firebase-database
Aditya Vyas-Lakhan May 2 '17 at 8:24 2017-05-02 08:24
source share