public class ProfilePictureServiceImpl { private static final String TAG = "ProfilePicServiceImpl"; private static final String UMEWIN_PROFILE = "UMW_PROFILE_%1$s.jpeg"; private static final String IO_ERROR = "IO Error"; public Uri getCameraProfilePicPath() { final File photoFile; try { photoFile = createCameraImageFile(); } catch (final IOException e) { Log.e(TAG, IO_ERROR, e); return null; } return Uri.fromFile(photoFile); } private static File createCameraImageFile() throws IOException { final String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); final String cameraPhotoFileName = String.format(UMEWIN_PROFILE, timeStamp); final File storageDir = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES); return new File(storageDir, cameraPhotoFileName); } }