0
private void processsearch(String s)
    {
        FirebaseRecyclerOptions<Calories> options =
                new FirebaseRecyclerOptions.Builder<Calories>()
                        .setQuery(FirebaseDatabase.getInstance().getReference().child("Food").orderByChild("Name").startAt(s).endAt(s+"\uf8ff"), Calories.class)
                        .build();

        adapter=new myadapter(options);
        adapter.startListening();
        recview.setAdapter(adapter);
        

    }

how can I make this search method case insensitive? I've tried doing

String n="Name";
n.equalsIgnoreCase()

; then replaced the word name in orderbychild with n but it didn't work I've also tried toLowerCase on n, I can't seem to find the method .equalsIgnoreCase() inside the recylcerOptions that's why i tried to do it on the outside

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

1

When you store your strings in your database, you should use a method to make it all lower case, such as string.toLowerCase().

And when you query, you convert your query to lower case as well query.toLowerCase()

there are other factors to consider such as special characters that should be removed/ignored but that is out of the scope of this question.

DIGI Byte
  • 4,225
  • 1
  • 12
  • 20