Created
August 11, 2015 09:30
-
-
Save asanand3/d66c7629a1701ee4fc87 to your computer and use it in GitHub Desktop.
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
try{ | |
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.bubble_green); | |
//replace "R.drawable.bubble_green" with the image resource you want to share from drawable | |
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); | |
largeIcon.compress(Bitmap.CompressFormat.JPEG, 40, bytes); | |
// you can create a new file name "test.jpg" in sdcard folder. | |
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "test.jpg"); | |
f.createNewFile(); | |
// write the bytes in file | |
FileOutputStream fo = new FileOutputStream(f); | |
fo.write(bytes.toByteArray()); | |
// remember close de FileOutput | |
fo.close(); | |
} | |
catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment