daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top