i have an android app which is having 4 fragments with navigation drawer with profile pic, but the thing is when i Change/Update the profile pic in Edit Profile Fragment the profile pic is updating in this fragment and also im saving the pic URL in Shared Preferences(also uploading to server), but when i come back to Home Fragment the profile picture in navigation drawer is not updating with the latest picture. I am using Glide lib. for loading the profile pic, this image is loading the URL which is stored in Shared preferences. But when i close my app and opens the profile picture in navigation drawer update with the latest picture taken. I can't ask the user to close the app and open whenever he changes his profile pic in Edit Profile Fragment. Is there any way to solve this problem?
//getting image URL from Shared Preferences.
imgUrl = Prefrences.getProfile_picture(HomeActivity.this);
loadImageUrl(imgUrl);
//loading image in navigation drawer with glide in Main Activity
private void loadImageUrl(String imgUrl) {
if (imgUrl != null && !imgUrl.isEmpty()) {
Glide.with(this).load(imgUrl).placeholder(R.drawable.avatar)
.crossFade()
.thumbnail(0.5f)
.bitmapTransform(new CircleTransform(this))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(img_profile);
} else {
getUserDetails(); <-- this method is called when imgUrl is Null,
}
}