I made this code below and I have problem with filling database. I want to download data from my database but somehow filling them is after fragment is choosen. Like firebase doesnt respect line by line behaviour.
Here fragment of code:
              Playlist x = new Playlist (0,"0","1988", true);
                x.setTitle("Spokojnie");
                x.setDescription("Kult");
                mAuth = FirebaseAuth.getInstance();
                database = FirebaseDatabase.getInstance();
                database_ref = database.getReference();
                final String[] album_array = new String[1];
                final String[] author_array = new String[1];
                ArrayList<Song> songs = new ArrayList<>();
                    if (mAuth.getCurrentUser() != null) {
                        database_ref.child("music").child("albums").child("Kult").child("Spokojnie").child("songs").addListenerForSingleValueEvent(new ValueEventListener() {
                            @Override
                            public void onDataChange(@NonNull DataSnapshot snapshot) {
                                album_array[0] = snapshot.getRef().getParent().getKey();
                                author_array[0] = snapshot.getRef().getParent().getParent().getKey();
                                 for (DataSnapshot ds: snapshot.getChildren()){
                                     System.out.println(ds.getKey().toString());
                                     Song local_song = new Song(0, author_array[0], album_array[0], ds.getKey().toString(),Uri.parse(ds.getValue().toString()));
                                    songs.add(local_song);
                                 }
                                x.setSongs(songs);
                                x.setImage_id(snapshot.child("image_id").getValue().toString());
                            }
                            @Override
                            public void onCancelled(@NonNull DatabaseError error) {
                            }
                        });
                    }
                selectedFragment = new CurrentPlaylistFragment(x);
Here my architecture on firebase side:

 
    