mohamed rimshadpcs
mohamed rimshadpcs

Reputation: 53

retrieve images from firebase storage to recyclerview without database

Hi guys I am making a wallpaper android app.I have stored all my images in firebase storage. Now I have a recyclerview and want to retrieve each of the images into that recyclerView by getting list url of the folders.Is there any way to do that without using the database.I have pasted the json file into my app.

Upvotes: 1

Views: 1697

Answers (2)

Alex Mamo
Alex Mamo

Reputation: 138824

In order to download a image/images from Firebase Storage, you first need to have the corresponding url/urls. To download an image, it requires four steps:

  1. Upload the image to Firebase Storage.
  2. Save the corresponding URL to Cloud Firestore/Firebase Database database while uploading.
  3. Attach a listener on the folder you have saved the image.
  4. Display the image.

So there is no way in which you can download an image without knowing the URL. You cannot get the image list URL directly from Firebase Storage.

Upvotes: 3

Tomas Ivan
Tomas Ivan

Reputation: 2320

First at all you need to have corresponding URLs of your image data stored in Firebase, as mention Alex Mamo. You can build list of this urls during upload or copy them from Firebase Console. Storage API doesn't provide any way how to retreive list of stored files.

Also, you can find Download URL in Image detail/properties. Then you can insert urls into JSON file (or another file, service, firebase storage, whatever) and load them in app.

But be careful, this is not a good idea because Firebase Storage (especially spark plan has limits) allow you download 1GB/day and only 50k/day (download/upload) operations. That will be wasted pretty soon if you don't optimise your data and number of reading operations.

Tip: When you select pay as you go most expensive is GB Downloaded, so you absolutely should store at least 1 thumbnail which will be shown in your recycler view.

enter image description here

Upvotes: 0

Related Questions