Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyFolder";
- File dir = new File(file_path);
- if(!dir.exists())
- {
- dir.mkdirs();
- }
- String name = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()).concat(".png");
- File file = new File(dir, name);
- FileOutputStream fOut;
- try {
- fOut = new FileOutputStream(file);
- bitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
- fOut.flush();
- fOut.close();
- return Uri.fromFile(file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
Add Comment
Please, Sign In to add comment