1

I have database of "date" "part" "heat" "defect" these all are child of defect

I tried to filter with date. It's working for 19/4/2021 fine. But not working for any other date. For any other that are present in database it showing result of first two data.

Please refer to these screenshots:

Full database

For 19/4/2021 filter

For any other date

com.google.firebase.database.Query query = defect.orderByChild("date").equalTo(query);
ValueEventListener valuelistener2 = new ValueEventListener() {
 @Override
   public void onDataChange(DataSnapshot _dataSnapshot) {
   map_list = new  ArrayList<>();
try {
 GenericTypeIndicator <HashMap<String, Object>> _ind = new GenericTypeIndicator<HashMap< String, Object>>() {};
 for (DataSnapshot _data : _dataSnapshot.getChildren()) {
 HashMap <String, Object> _map= _data.getValue(_ind);
 map_list.add(_map);
}

I also have attached source code photo heresource Source 1

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
vasu dev
  • 21
  • 5
  • Could you please provide how the dates look in the RTD and log the `query` value. If you for example store the data as Date type but search over it with a String they will not be considered as equal. The Date type stores with it additional data like time zone. – Tarik Huber Apr 23 '21 at 07:39
  • I think I'm keeping date in string format only . now I have added data you have requested – vasu dev Apr 23 '21 at 10:11
  • I couldn't share I don't have 10 reputation . Sorry bro – vasu dev Apr 23 '21 at 10:13
  • } public static class DatePickerFragment extends androidx.appcompat.app.AppCompatDialogFragment implements DatePickerDialog.OnDateSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); return new DatePickerDialog(getActivity(), this, year, month, day); } public void onDateSet(DatePicker view, int year, int month, int day) { int mon = month +1; String date = day + "/" + mon + "/" + year; – vasu dev Apr 23 '21 at 10:15
  • No Problem. We will firgure this out :) – Tarik Huber Apr 23 '21 at 11:04
  • Can you make a screenshot of your data in the Realtimedatabase and just post the URL here in the comments. It is very important the the data is exactly the same in the database and when you query for it. Even the smallest difference will break the query. – Tarik Huber Apr 23 '21 at 11:06
  • https://ibb.co/ZBCSDr3 https://ibb.co/PjCx3cR https://ibb.co/WKyBkBZ – vasu dev Apr 23 '21 at 11:31
  • I found something. If database contains 4 of 19/4/2021 string it returns first four data from the database . If it found 2 matches then it returns first two from the database. What can be done to rectify this . – vasu dev Apr 23 '21 at 23:52

0 Answers0