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.
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[])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With