Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i know the documentation do it like this

     listRef.listAll()
    .addOnSuccessListener(new OnSuccessListener<ListResult>() {
        @Override
        public void onSuccess(ListResult listResult) {
            for (StorageReference prefix : listResult.getPrefixes()) {
                // All the prefixes under listRef.
                // You may call listAll() recursively on them.
            }

            for (StorageReference item : listResult.getItems()) {
                // All the items under listRef.
            }
        }
    }) 


but how can i get my data out of item? like the image uri or metadata
public class Wallpaper {
private String wallpaperName;
private Uri imageUri;


public Wallpaper(String wallpaperName, Uri imageUri) {
    this.wallpaperName = wallpaperName;
    this.imageUri = imageUri;
}

public Wallpaper() {
}

public String getWallpaperName() {
    return wallpaperName;
}

public void setWallpaperName(String wallpaperName) {
    this.wallpaperName = wallpaperName;
}

public Uri getImageUri() {
    return imageUri;
}

public void setImageUri(Uri imageUri) {
    this.imageUri = imageUri;
}
}





public class ShowWallpapers extends AppCompatActivity {

private RecyclerView recyclerView;
private RecyclerViewAdapter recyclerViewAdapter;

private List<Wallpaper> wallpaperList;
private StorageReference storageReference;

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

    storageReference = FirebaseStorage.getInstance().getReference("wallpapers");

    recyclerView = findViewById(R.id.recyclerview);
    recyclerView.setHasFixedSize(true);

    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    wallpaperList = new ArrayList<>();


    storageReference.listAll()
            .addOnSuccessListener(new OnSuccessListener<ListResult>() {
                @Override
                public void onSuccess(ListResult listResult) {
                    for (StorageReference item : listResult.getItems()) {
                   // i want to set-up my Wallpaper object here and add it to my list
                  // but how can i do that


                    }
                    recyclerViewAdapter = new RecyclerViewAdapter(ShowWallpapers.this,
                            wallpaperList);
                    recyclerView.setAdapter(recyclerViewAdapter);
                }


            }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {

        }
    });
}
}

my storage: https://i.imgur.com/jnjW6Ko.png[^]

What I have tried:

There was nothing i could try.
Posted
Updated 3-Sep-21 7:51am
v3

// Do this step by step :-
// 1. import * as firebase from firebase;

// write below codes in any function where you want to list all items of firebase storage
var storageRef = firebase.storage().ref("your file path");

storageRef.listAll().then( res => {
   // for folders
   res.perfixes.forEach( folder => {
      console.log(folder);
   });
   // for files like images
   res.items.forEach( item => {
      console.log( item.name ); 
   });
})


// don't forgot to update your security rule version in firebase
// just write on top in your firebase storage security rule ---- rules_version = "2"
 
Share this answer
 
Comments
hiwa doski 23-Nov-19 20:44pm    
thanks but that syntax look very weird to me, can you please do it in Java.
Thank you soo much for your help, I'm not understant the firebase documentation thank you soo much
 
Share this answer
 
Comments
CHill60 3-Sep-21 18:48pm    
If you want to comment on an answer please use tbe "Have a Comment or Question" link next to it. This is not a "Solution"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900