private Uri findCreateSubdirectory(final Uri dirUri, final String dirName, final boolean createIfNotExisting) throws IOException {
        final List<Uri> result = queryDir(dirUri, new String[]{DocumentsContract.Document.COLUMN_DOCUMENT_ID, DocumentsContract.Document.COLUMN_DISPLAY_NAME, DocumentsContract.Document.COLUMN_MIME_TYPE}, c -> {
            if (dirName.equals(c.getString(1)) && DocumentsContract.Document.MIME_TYPE_DIR.equals(c.getString(2))) {
                return DocumentsContract.buildDocumentUriUsingTree(dirUri, c.getString(0));
            }
            return null;

        });
        for (Uri uri : result) {
            if (uri != null) {
                return uri;
            }
        }
        if (createIfNotExisting) {
            try {
                return DocumentsContract.createDocument(getContext().getContentResolver(), dirUri, DocumentsContract.Document.MIME_TYPE_DIR, dirName);
            } catch (RuntimeException re) {
                Log.e("Could not create dir '" + dirName + "' in '" + dirUri + "'", re);
            }
        }
        return null;
    }
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