Question

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?

No correct solution

OTHER TIPS

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().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top