private Uri getSubdirUri(@NonNull final Uri baseUri, @NonNull final List<String> subdirs, final boolean needsWrite, final boolean createIfNeeded, final boolean validateCache) throws IOException {

        //try to find parent entries in cache
        Uri dir = baseUri;
        int subdirIdx = subdirs.size();
        while (subdirIdx > 0) {
            final String cacheKey = uriCacheKey(baseUri, subdirs, subdirIdx);
            final Uri cachedDir = findInUriCache(cacheKey, needsWrite, validateCache);
            if (cachedDir != null) {
                dir = cachedDir;
                break;
            }
            subdirIdx--;
        }

        //from cache entry work up and find/create missing dirs
        while (subdirIdx < subdirs.size()) {
            final String subfolderName = subdirs.get(subdirIdx);
            final Uri child = findCreateSubdirectory(dir, subfolderName, createIfNeeded);
            if (child == null) {
                if (createIfNeeded) {
                    throw new IOException("Failed to create subdir " + subfolderName + " for dir " + dir + ": reason unknown");
                } else {
                    return null;
                }
            }
            dir = child;
            subdirIdx++;
        }

        putToUriCache(uriCacheKey(baseUri, subdirs, -1), dir);
        return dir;
    }
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