I have a ListView
. Within the list view, I want to fetch data from the Firebase database. I am able to show title, count in the activity. I want to fetch how many status shows unread and it will be semester Wise.
unread_count not working.
Below is the database structure:
I have tried below but unable to fetch unread_count. It always shows 0
databaseReference = FirebaseDatabase.getInstance().getReference("All_Image_Uploads_Database");
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list = new ArrayList<ListType>();
list.clear();
for (DataSnapshot postSnapshot:dataSnapshot.getChildren()){
String count = String.valueOf(postSnapshot.getChildrenCount());
String title = postSnapshot.getKey();
String unread_count = String.valueOf(postSnapshot.child("status").getChildrenCount());
ListType listType = new ListType(title, count, unread_count);
list.add(listType);
}
ListTypeList listTypeList = new ListTypeList(HomeActivity.this, list);
listView.setAdapter(listTypeList);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
I need to fetch how many "status" shows "unread". It means to count the numbers of "unread" in semester wise.
I need your suggestion of how I will get the required data.