private <T> List<T> queryDir(final Uri dirUri, final String[] columns, final Func1<Cursor, T> consumer) throws IOException, IllegalArgumentException {

        if (dirUri == null) {
            return Collections.emptyList();
        }

        final List<T> result = new ArrayList<>();
        final ContentResolver resolver = getContext().getContentResolver();
        final Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(dirUri, DocumentsContract.getDocumentId(dirUri));

        Cursor c = null;
        try {
            c = resolver.query(childrenUri, columns, null, null, null);
            if (c == null) {
                throw new IllegalArgumentException("Cursor is null");
            }
            while (c.moveToNext()) {
                result.add(consumer.call(c));
            }
            return result;
        } catch (IllegalArgumentException iae) {
            //this is thrown if dirUri does not exist (any more). Rethrow
            throw iae;
        } catch (SecurityException se) {
            //tis is thrown if dirUri has no permission any more
            throw new IllegalArgumentException("No permission", se);
        } catch (Exception e) {
            throw new IOException("Failed dir query for '" + dirUri + "' cols [" + CollectionStream.of(columns).toJoinedString(",") + "]", e);
        } finally {
            closeQuietly(c);
        }

    }
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