Android: Save image to SD card

File sdCardDirectory = Environment.getExternalStorageDirectory();
File image = new File(sdCardDirectory, "test.png");
// Encode the file as a PNG image.
FileOutputStream outStream;
try {
  outStream = new FileOutputStream(image);
  bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
  outStream.flush();
  outStream.close();
} catch (FileNotFoundException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}

Werbung



comments powered by Disqus

Copyright Dunkel & Iwer GbR | Datenschutzerklärung | Impressum