I have two tables in firebase database.
Table A : Table B:
a a 2 pic
b b 3 pic
c
d d 1 pic
e
Result shows as :
a 2 pic
b 3 pic
d 1 pic
I need result as :
a 2 pic
b 3 pic
c 0 pic
d 1 pic
e 0 pic
I am unable How I will write the query.
I write the query as if a from Table A, equals a in Table B, then a will show with 2 pic. In this way, a,b and d shows. But c and e are not showing as c and e not equal in Table B. I want to show c and e with 0 pictures.
What I have tried:
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list = new ArrayList<ListType>();
list.clear();
for(DataSnapshot ds:dataSnapshot.getChildren()) {
ListType listType = ds.getValue(ListType.class);
final String listname = listType.getName();
databaseReference1.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot postSnapshot:dataSnapshot.getChildren()) {
if (postSnapshot.getKey().equals(listname)) {
String count = String.valueOf(postSnapshot.getChildrenCount());
ListType listTypee = new ListType(listname, count);
list.add(listTypee);
adapter.notifyDataSetChanged();
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}