1

Since im new in Android coding i have one question, how just to retrieve images from folder from Firebase for Android? I did my search on topic but im too noob in this matter im asking this, I was following tuts on youtube nothing came in hand, can somebody help me with the code?

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Peter Kostov
  • 19
  • 1
  • 3
  • This question does not show research effort. If you are having problems please post your current best guess. You should review [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Stefan Crain Apr 06 '18 at 17:26

2 Answers2

1

Assuming you are using Firebase Storage to host your images, in order to display a image from a folder to an ImageView, you can use one of the following libraries: Glide or Picasso.

If you want to display all the images within a folder, first you need to store them. In order to make it work, when you are uploading an image to Firebase Storage, store the corresponding url in Firebase database. Your database should look like this:

Firebase-root
   |
   --- images
         |
         --- imageUrl1: "https://..."
         |
         --- imageUrl2: "https://..."

In order to get all those url's, just attach a listener on the images node and get all the url's from the DataSnapshot object like this:

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference imagesRef = rootRef.child("images");
ValueEventListener valueEventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            String url = ds.getValue(String.class);
            Log.d("TAG", url);
        }
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
imagesRef.addListenerForSingleValueEvent(valueEventListener);
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • How is xml look like ? with pictureviewr or something else ? – Peter Kostov May 10 '18 at 16:36
  • If you are interested, **[this](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849)** is how you can retrieve data from a Firebase Realtime database and display it in a `RecyclerView` using `FirebaseRecyclerAdapter`. – Alex Mamo May 11 '18 at 10:34
  • Do you think that my answer helped you? – Alex Mamo May 11 '18 at 10:34
0

Use Glide with FirebaseImageLoader.

compile 'com.github.bumptech.glide:glide:3.7.0'

Sample:

Glide.with(CONTEXT).using(new FirebaseImageLoader()).load(IMAGE_URL).into(IMAGE_VIEW);
Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126