Guest User

Untitled

a guest
Jul 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.image);
  2.  
  3. String path = Environment.getExternalStorageDirectory().toString();
  4. OutputStream out = null;
  5. File file = new File(path, "imagename.jpg");
  6.  
  7. try {
  8. out = new FileOutputStream(file);
  9. bm.compress(Bitmap.CompressFormat.PNG, 100, out);
  10. } catch (Exception e) {
  11. e.printStackTrace();
  12. } finally {
  13. try {
  14. if (out != null) {
  15. out.close();
  16. }
  17. } catch (IOException e) {
  18. e.printStackTrace();
  19. }
  20. }
Add Comment
Please, Sign In to add comment