public static String toCompareString(final Uri uri) {
        if (uri == null) {
            return null;
        }
        //replace encoded characters
        String uriString = uri.toString().replaceAll("%2F", "/").replaceAll("%3A", ":").trim();
        // remove trailing /
        // This is important because: folders returned by Document Intents may have trailing / while persisted Uris for same folder may not!
        while (uriString.endsWith("/")) {
            uriString = uriString.substring(0, uriString.length() - 1);
        }
        return uriString;
    }
Returns a string reporesentation of Uri fit for comparison with other Uris (e.g. to heck for equality).
<br>
This method tweaks the Uri string such that Uris different in string representation but pointing
to same physical folder have a higher chance to match. It does not, however, guarantee that
two Uris pointing to the same physical folder will get same string rep (this is simply not possible to achieve)
<br>
Returned strings may NOT be used to reconstruct an Uri using Uri.parse()!
main/src/main/java/cgeo/geocaching/utils/UriUtils.java