private <T> T queryDoc(final Uri docUri, final String[] columns, final T defaultValue, final Func1<Cursor, T> consumer) throws IOException {
        final ContentResolver resolver = getContext().getContentResolver();

        Cursor c = null;
        try {
            c = resolver.query(docUri, columns, null, null, null);
            if (c == null) {
                throw new IllegalArgumentException("Cursor is null when querying Uri '" + docUri + "'");
            }
            if (c.moveToFirst()) {
                return consumer.call(c);
            } else {
                return defaultValue;
            }
        } catch (IllegalArgumentException iae) {
            //this is thrown if dirUri does not exist (any more). Rethrow
            throw iae;
        } catch (SecurityException se) {
            //this is thrown if dirUri has no permission any more
            throw new IllegalArgumentException("No permission", se);
        } catch (Exception e) {
            throw new IOException("Failed query for '" + docUri + "' 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