Created
February 18, 2018 00:25
-
-
Save valterh4ck3r/c9570273dea281db1a3ab2f16bbe24fb to your computer and use it in GitHub Desktop.
Save Image File in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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