Storing a gif image in the built-in memory of Android

I am brand new to android. I want to save the image to internal memory, and then restore the image from internal memory and load it into image view mode. I successfully saved 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 jpg-image. If I want to save a gif image, how can I do this? Please help me. I see options only for jpg and png.

+5
source share
1 answer

The bitmap only works with png, jpg, etc., and gif is a list of images, so you need to work with it as a binary file and use FileOutputStream andwrite(byte[])

+1

All Articles