Skip to content
Advertisement

Want to list all the files in a child of firebase storage and share the ArrayList to set it in the recycler view for a android App [closed]

In my firebase storage i have a child which contains subfolder and on these folder some contains files while some contains data, I want to list out all the data in all the folders. and pass it to recycler View.

Advertisement

Answer

I guess you want to do something like this:

FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference listRef = storage.getReference().child("Wallpapers");

listRef.listAll()
        .addOnSuccessListener(listResult -> {
            // All the items under listRef.
            images.addAll(listResult.getItems());
            adapter.notifyDataSetChanged();
            //....
        })
        .addOnFailureListener(e -> {
            // Uh-oh, an error occurred!
            Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
            //...
        });

Edit: images is an ArrayList object like this:

private ArrayList<StorageReference> images;
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement