Guest User

Untitled

a guest
Jul 11th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyFolder";
  2. File dir = new File(file_path);
  3.  
  4. if(!dir.exists())
  5. {
  6. dir.mkdirs();
  7. }
  8.  
  9. String name = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()).concat(".png");
  10. File file = new File(dir, name);
  11.  
  12. FileOutputStream fOut;
  13. try {
  14. fOut = new FileOutputStream(file);
  15. bitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
  16. fOut.flush();
  17. fOut.close();
  18.  
  19. return Uri.fromFile(file);
  20. } catch (Exception e) {
  21. e.printStackTrace();
  22. }
  23.  
  24. return null;
Add Comment
Please, Sign In to add comment