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

452 views Asked by At

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.

1

There are 1 answers

0
Sujal Kumar On BEST 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;