I am trying to store image from firebase database and named it FirebaseuniqUserID.jpeg.(like buwkgefuikbuifbkc8gfybfy.jpeg). And user can change image anytime. For getting image link from firebase realtime database i used addListenerForSingleValueEvent.
FirebaseDatabase.getInstance().getReference().child("Users").child(FirebaseuniqUserID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
//here i am downloading image//
//and named it FirebaseuniqUserID.jpeg
}
Now the problem is this when this listener is called every time image is download. But now i want avoid downloading if current user has latest updated image of user in firebase to reduce firebase downloaded data.
You can use two different options, first is Glide and 2nd is that, you can save image downloading status in your local database file or SharePreferences. But image cache is the best solution.
To solve this, I definitely recommend you to use an image loading and caching library. For Android we have Glide: