SoFunction
Updated on 2025-03-02

How to save Bitmap object to SD card in android

This article example describes how android saves Bitmap objects to SD card. Share it for your reference. The details are as follows:

Bitmap logoBitmap = ((), .arcnote_logo);
ByteArrayOutputStream logoStream = new ByteArrayOutputStream();
boolean res = (,100,logoStream);
//Read the image into the logoStreambyte[] logoBuf = ();
//Save the image to byte[]Bitmap temp = (logoBuf,0,);
//Read the image from byte[] to generate Bitmap object tempsaveMyBitmap("tttt",temp);
//Save the image to the SD cardpublic void saveMyBitmap(String bitName,Bitmap mBitmap){
 File f = new File("/sdcard/" + bitName + ".png");
 try {
  ();
 } catch (IOException e) {
  // TODO Auto-generated catch block
 }
 FileOutputStream fOut = null;
 try {
  fOut = new FileOutputStream(f);
 } catch (Exception e) {
  ();
 }
 (, 100, fOut);
 try {
  ();
 } catch (IOException e) {
  ();
 }
 try {
  ();
 } catch (IOException e) {
  ();
 }
}

I hope this article will be helpful to everyone's Android programming design.