Search code examples
androidandroid-imageview

ImageView - Permanent change of default source image


My application is stated with default image for the an ImageView which i located at the Drawable folder.

As part of the application, the user have any option to replace default image with his own image from his Gallery.

I was able to retrieved an image from the Gallery and able to replace the default image but when the activity is re-invoke the default image is shown again.

My question is, how i permanent change of default source image to the chosen image so when application will be restarted or when the activity is re-invoke, it will present the new chosen image.


Solution

  • You can save path of photo from gallery to SharedPreferences and with every run of the App, check if something is saved in SharedPreferences. If not, display default photo from Drawable but if there is something saved, take saved path and set it to ImageView.