Question: I have a app in building proccess in some where i need to get data from FirebaseDatabase and show them in custom list view here my code part of it for onDataChange method

```
    myDatabase=FirebaseDatabase.getInstance();
    myRef= myDatabase.getReference().child("TvSeries");
    myAuth  = FirebaseAuth.getInstance();
    myUser = myAuth.getCurrentUser();

    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for(DataSnapshot currentData : dataSnapshot.getChildren()){
                if(currentData.child("tCategory").child("tPrimary").getValue().toString().equals("Aksiyon")){ }
                selectedCategoryList.add(new  DataForRow(currentData.getKey(),
                        currentData.child("tCategory").child("tPrimary").getValue().toString(),
                        currentData.child("tReleaseDate").getValue().toString()));

            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

    Integer size =selectedCategoryList.size();
    Log.d("Size:",  size.toString());

```

When i put in breakpoint onDataChange method it works but otherwise it didnt any suggestion is very helpful. Have a nice day all.

Answer: 
Your `selectedCategoryList` list is always empty because `onDataChange()` method has an asynchronous behaviour which means that is called even before you are try to add those objects of `DataForRow` class to the list. A quick solve for this problem would be to declare and use your `selectedCategoryList` list only inside the `onDataChange()` method or if you want to use it outside, you need to create your own callback and for that, I recommend you see the last part of my answer from this **[post](https://stackoverflow.com/questions/47847694/how-to-return-datasnapshot-value-as-a-result-of-a-method/47853774)**.
Firebase works asynchronously. You probably got the data from firebase after you program executed the line with Log. As Tristan mentioned, if you put your Log inside of the listener, it will work