set Bitmap to a file by file name - Android android.graphics

Android examples for android.graphics:Bitmap Load Save

Description

set Bitmap to a file by file name

Demo Code

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import android.content.Context;
import android.graphics.Bitmap;

public class Main {

  public static void setInternalBitmap(Context c, String filename, Bitmap bitmap) {

    try {/*from   ww  w  .  jav  a  2 s .  c o m*/
      FileOutputStream fos = c.openFileOutput(filename, Context.MODE_PRIVATE);
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }

}

Related Tutorials