0

i'm trying with below code

 Query queryAll = FirebaseDatabase.getInstance().getReference("Food Users")
                            .orderByChild("userName")
                            .startAt(newText)
                            .endAt(newText+ "\uf8ff");

then i found solution from this link

above solution say like

 Query queryAll = FirebaseDatabase.getInstance().getReference("Food Users")
                            .orderByChild("userName")
                            .startAt(newText.toUpperCase())
                            .endAt(newText.toLowerCase() + "\uf8ff");

but it doesn't work so please help me i found data successfully when i'm type data as stored in firebase database but when i'm entered data in lowercase then that existing data not return by firebase query please help me

  • show your firebase data and what it is in newText ? – Faiizii Awan Sep 02 '18 at 14:02
  • new text is a data which is entered by the user in edittext and this query is fired when user entered any text in edittext – Nikul Vaghani Sep 02 '18 at 14:04
  • That answer is not clear enough on the fact that you will need to store `userName` in all uppercase for that second snippet to work. Or all lowercase as shown here: https://stackoverflow.com/questions/37643459/case-insensitive-sorting-with-firebase-orderbychild – Frank van Puffelen Sep 02 '18 at 14:22
  • why are you marked as duplicate this question is not duplicate whatever answered are given to the respected user which are not full fill worked so that's why i'm posted new question @ Frank van Puffelen – Nikul Vaghani Sep 02 '18 at 14:37

1 Answers1

1

sorry it cant be done. if you want then you need to keep/store both versions of text(lowercase and uppercase) because data in firebase is case sensitive.

there is another approach of doing this. you can searching in code part but for that you have to get all the data then perform the search which may effect your bandwidth (if data exists in large volume) as well as you device performance.

you said query perform only if data in firebase exists in both forms

Hope this is helping

Faiizii Awan
  • 1,615
  • 1
  • 13
  • 28
  • yeah man i will implement with two field for username one is original and another is for back end side management called usernameLower which will be stored username in lowercase and inside the query we are getting the value of usernameLowercase – Nikul Vaghani Sep 02 '18 at 15:02
  • ;-) then i think ans is acceptable @NikulVaghani – Faiizii Awan Sep 02 '18 at 15:04
  • sorry to say but your idea is acceptable till my answer i'm not getting from firebase query :), and your idea is work well :) thank you – Nikul Vaghani Sep 02 '18 at 15:07