Skip to content

Instantly share code, notes, and snippets.

@valterh4ck3r
Created February 18, 2018 00:25
Show Gist options
  • Save valterh4ck3r/c9570273dea281db1a3ab2f16bbe24fb to your computer and use it in GitHub Desktop.
Save valterh4ck3r/c9570273dea281db1a3ab2f16bbe24fb to your computer and use it in GitHub Desktop.
Save Image File in Android
public static void saveImage(Bitmap bitmapImage) {
File root = new File(Environment.getExternalStorageDirectory(), "Identidata");
if (!root.exists()) {
root.mkdirs();
}
File mypath = new File(root,"debug.jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(mypath);
// Use the compress method on the BitMap object to write image to the OutputStream
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment