@Nullable
    public static String getLastPathSegment(final Uri uri) {
        if (uri == null) {
            return null;
        }
        final String lastPathSegment = uri.getLastPathSegment();
        if (lastPathSegment == null) {
            return null;
        }
        final String[] tokens = lastPathSegment.split("/");
        if (tokens == null) {
            return lastPathSegment.trim();
        }
        return tokens[tokens.length - 1] == null ? null : tokens[tokens.length - 1].trim();
    }
Tries to extract the last path segment name of a given Uri, removing "/" and such
main/src/main/java/cgeo/geocaching/utils/UriUtils.java