I'm making an app and I need to match data continuously in the activity. I'm using firebase for the database and I'm getting problem of getting my query right. I want to match the data in child(uid) to other data in different child(uid), in this case I'm still testing with only the date.
EDIT: I need to match the child of uid1 (for this case, the date) to ALL EXISTING dates available in the "Schedules". My bad.. the previous question stated was wrong where i said "matching the uid1 data to uid2 data"
Here is my code. I think my conditions aren't correct.
mInstance.getReference("Schedules").addValueEventListener(new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Schedule schedule = dataSnapshot.child(uid).getValue(Schedule.class);
for(DataSnapshot data: dataSnapshot.getChildren()) {
if (dataSnapshot.child(uid).child("date").exists() && dataSnapshot.child(uid).child("date").getChildrenCount()>= 2) {
test.setText("Found Match for " + schedule.date + "," + schedule.sport + ", and " + schedule.location);
} else {
test.setText(schedule.date + schedule.sport + schedule.location);
}
}
}
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}