I am new in Android. I want to store my bitmap in sharedPreferences. Can anyone tell me how it will possible? Actually my requirements is, I fetch the image from gallery as well as take picture from camera and I set that Bitmap in my ImageView. These all things work properly. But when I click on back button all ImageView will be empty.
So I want to store that Bitmaps throughout my application.
Can anyone help me? I am very much stuck on this.
Thanks.
Hey friends I got the solution of my problem here I post my code so that others can use this solution..
1). on button click – open camera for captureing image
2). on button cllick – open Gallery for select image
3). Static variables
4). onActivityResult
5). in onDestroy()
You have to destroy all bitmap which you setted.
6). At the time when you fetch data from sharedPrefrences you have to convert string in to Bitmap and then you can set bitmap in ImageView.
for example, Bitmap bit1 = BitmapFactory.decodeFile(strimg1);
and then set , imageView.setImageBitmap