Why i can't get my array from another class : I have an activity, in which i have to use function from another class DataBase . In DataBase code have to get information from my FireBase database, and then return ArrayList<String> as a result. But when i use function `takeDataFromFirebase` my array in null, it's size is null. How i can get the array with FireBase information to my actvity?

    public class DataBase{    
    public ArrayList<String> arraylist = new ArrayList<>();
    public ArrayList<String> takeDataFromFirebase(DatabaseReference dRef) {
            usersRef = dRef.child(USERS_CHILD);
            ValueEventListener valueEventListener = new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    for(DataSnapshot ds : dataSnapshot.getChildren()) {
                        String userKey = ds.getKey();
                        DatabaseReference messagesRef = usersRef.child(userKey).child(USER_MESSAGES);
                        ValueEventListener eventListener = new ValueEventListener() {
                            @Override
                            public void onDataChange(DataSnapshot dataSnapshot) {
                                for(DataSnapshot dSnapshot : dataSnapshot.getChildren()) {
                                    messageText = dSnapshot.child(USER_MESSAGE_TEXT).getValue(String.class);
                                    arrayList.add(messageText);
                                }
                            }
                            @Override
                            public void onCancelled(DatabaseError databaseError) {}
                        };
                        messagesRef.addListenerForSingleValueEvent(eventListener);
                    }
                }
                @Override
                public void onCancelled(DatabaseError databaseError) {}
            };
            usersRef.addListenerForSingleValueEvent(valueEventListener);
    
            return null;
        }
    }

and my activity where i use this method:

    public class Categories extends AppCompatActivity{


    private static final String TAG = "CATEGORIES";
    FirebaseAuth mAuth;

    private ListView all_problems_list_view;
    private Button add_problem_button, signOut;
    private static long back_pressed;


    FirebaseDatabase mDataBase;
    DatabaseReference dRef;
    DatabaseReference userRef;
    DataBase dataBaseFunctions;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(layout.activity_categories);

        dataBaseFunctions = new DataBase();
        mAuth = FirebaseAuth.getInstance();


        mDataBase = FirebaseDatabase.getInstance();
        dRef = mDataBase.getReference();
        userRef = dRef.child("Users");
        //region add all items

        all_problems_list_view = (ListView) findViewById(id.all_problems_list_view);
        add_problem_button = (Button) findViewById(id.add_problem_button);
        signOut = (Button) findViewById(id.SignOutBut);
        //endregion

        //region set onClick to buttons
        signOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logout();
            }
        });

        add_problem_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(Categories.this, sendEmailActivity.class));
            }
        });


        //endregiond



        ArrayList<String> list = dataBaseFunctions.takeDataFromFirebase(dRef);
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
                android.R.layout.simple_list_item_1, list);
        all_problems_list_view.setAdapter(adapter);


    }