Code example for File

Methods: canWriteexists

    // TODO: Super gnarly (copied from, do cleanup. 
    public static File getFinalSaveDirectory(Context context, Uri sourceUri) {
        File saveDirectory = getSaveDirectory(context, sourceUri);
        if ((saveDirectory == null) || !saveDirectory.canWrite()) {
            saveDirectory = new File(Environment.getExternalStorageDirectory(),
        // Create the directory if it doesn't exist 
        if (!saveDirectory.exists())
        return saveDirectory;
    public static String getNewFileName(long time) {
        return new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(time));
Connect your IDE to all the code out there  Get Codota for Java