private boolean checkUriPermissions(final Uri uri, final boolean checkWrite) {
        if (uri == null) {
            return false;
        }

        final UriPermission perm = this.uriPermissionCache.get(UriUtils.toCompareString(uri));
        if (perm == null) {
            // This happens when we use temporary folder uris (they have no entry in persistent permission cache).
            // Return true in this case
            return true;
        }

        return perm.isReadPermission() && (!checkWrite || perm.isWritePermission());
    }
Gets the Folder File; creates it if necessary and performs all possible error handlings.
This is used for locations of Type DOCUMENT and FILE
<br
This method is in many respects the core method of this class

@param folder folder to get file for
@return file folder, or null if creation/retrieving was not at all possible
main/src/main/java/cgeo/geocaching/storage/DocumentContentAccessor.java