Reputation: 2805
I am quite new to android. I want to save image to internal memory and later retrieve the image from internal memory and load it to image view. I have successfully stored the image in internal memory using the following code :
void saveImage() {
String fileName="img"+ cnt +".jpg";
//File file=new File(fileName);
try
{
FileOutputStream fOut=openFileOutput(fileName, MODE_PRIVATE);
bmImg.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
}
catch (Exception e)
{
e.printStackTrace();
}
}
This code is for saving the jpg image. If I want to save a gif image how can i do that?? Please help me. I can see the options for only jpg and png.
Upvotes: 6
Views: 2242
Reputation: 3893
Bitmap only works with png, jpg etc, and gif is a list of images, so you have to work with it as a binary file and use FileOutputStream and write(byte[])
Upvotes: 1