0

I am new to android.

I created an Image View to display an image from the file browser and this is working correctly.

The problem is once i come out of my application and open it again. The image I selected isn't there in the image view.

That means only at the time I am using my application, the image is present inside the imageview. The next time I open it, the image is vanished and I have to select the image from the file browser again.

So how can I store the image permanently inside the imageview until I change that image?

1
  • It is better to reload the image when you start up the app again. Take a look at Square's Picasso, it makes image loading a lot easier. github.com/square/picasso
    – ejohansson
    Feb 4, 2014 at 13:30

1 Answer 1

1

You can not "store images in an ImageView" persistently because ImageView is not a persistent object. It is recreated every time your activity calls setLayout() losing all state it may have had (or, to be exact, it doesn't exactly lose it's state because it gets replaced by a completely new blank ImageView).

Instead you need to store the image to a persistent storage (if you loaded it from the internet, for example) and reload it in onCreate().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.