public static Uri appendPath(final Uri uri, final String path) {
        if (uri == null || StringUtils.isBlank(path)) {
            return uri;
        }
        String pathToAppend = path.trim();
        while (pathToAppend.startsWith("/")) {
            pathToAppend = pathToAppend.substring(1);
        }
        while (pathToAppend.endsWith("/")) {
            pathToAppend = pathToAppend.substring(0, pathToAppend.length() - 1);
        }
        if (StringUtils.isBlank(pathToAppend)) {
            return uri;
        }
        return Uri.withAppendedPath(uri, pathToAppend);
    }
if given Uri is a file uri, then the corresponding file is returned. Otherwise null is returned
main/src/main/java/cgeo/geocaching/utils/UriUtils.java