2

I am facing a issue with my app, wherein I am displaying the image which is stored in FirebaseStorage

Below is the Code snippet i am using to get the file(file.png):

 mFirebaseStorage = FirebaseStorage.getInstance();
 mFirebaseStorageRef = mFirebaseStorage.getReference().child("folder/file.png");

And displaying it using Glide as:

 ImageView imgView = (ImageView) rootView.findViewById(R.id.imgView);

 Glide.with(rootView.getContext() /* context */)
                    .using(new FirebaseImageLoader())
                    .load(mFirebaseStorageRef)
                    .into(imgView);

And I have also Enabled Persistence for Firebase as its required for my other functionality using firebasedatabase.
So once i loggedin/open my app I am gettign this image(file.png) correctly, but when i tried replacing/overwriting this "file.png" on my firebasestorage the new Image is NOT getting reflected in my app.
I understand that as I am using Persist Enabled, firebase is caching the data locally & not making new requests to remote, i even tried loging-out & login again but still its shows the old image & it only resolves when clearing my app's cache.
so, is there any way to resolve this issue?
Thanks :)

  • Enabling local persistence creates a disk cache for recently seen data. But once you attach a listener, the Firebase SDK will still try to get the updated data from the server. So it's unlikely that this is causing your problems, although it is hard to be certain without seeing an [MCVE](http://stackoverflow.com/help/mcve) (read the link, it's quite useful) that includes the database code. – Frank van Puffelen Jun 06 '17 at 15:10
  • 1
    Glide caches downloaded images. See this related question: https://stackoverflow.com/q/33443146/4815718 – Bob Snyder Jun 06 '17 at 16:21
  • Thx @ Frank van Puffelen for the response, I checked the MCVE link u shared, but the code i shared earlier is the only code I am using w.r.t firebaseStorage & there's no further database code to this. So the MCVE u suggested will have a extra to my above code is the google-services.json for firebase project, so is this what u were suggesting if i understood u correctly ? And for the listenere part I don't have any listner attached to this storageref, i referred below link for src: [link](https://firebase.google.com/docs/storage/android/download-files#Downloading Images with FirebaseUI) – Scorpion_Abhi Jun 07 '17 at 05:54
  • Thx @BobSnyder for the response, i went through he link u shared, I will try test that, but with the changes suggested there, for not caching or requesting new image every time doesn't solve my problem, as i was expecting the image will get updated only when the content changes not otherwise, like we have _valueEventListner_ for friebasedatabase, but the code/src i reffered is from: (https://firebase.google.com/docs/storage/android/download-files#Downloading) where there is no listener to handle such a change. Thanks – Scorpion_Abhi Jun 07 '17 at 07:12

0 Answers0