compat/src/main/java/androidx/core/content/FileProvider.java
@Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
            @Nullable String[] selectionArgs,
            @Nullable String sortOrder) {
        // ContentProvider has already checked granted permissions
        final File file = mStrategy.getFileForUri(uri);

        if (projection == null) {
            projection = COLUMNS;
        }

        String[] cols = new String[projection.length];
        Object[] values = new Object[projection.length];
        int i = 0;
        for (String col : projection) {
            if (OpenableColumns.DISPLAY_NAME.equals(col)) {
                cols[i] = OpenableColumns.DISPLAY_NAME;
                values[i++] = file.getName();
            } else if (OpenableColumns.SIZE.equals(col)) {
                cols[i] = OpenableColumns.SIZE;
                values[i++] = file.length();
            }
        }

        cols = copyOf(cols, i);
        values = copyOf(values, i);

        final MatrixCursor cursor = new MatrixCursor(cols, 1);
        cursor.addRow(values);
        return cursor;
    }
/**
     * Use a content URI returned by
     * {@link #getUriForFile(Context, String, File) getUriForFile()} to get information about a file
     * managed by the FileProvider.
     * FileProvider reports the column names defined in {@link android.provider.OpenableColumns}:
     * <ul>
     * <li>{@link android.provider.OpenableColumns#DISPLAY_NAME}</li>
     * <li>{@link android.provider.OpenableColumns#SIZE}</li>
     * </ul>
     * For more information, see
     * {@link ContentProvider#query(Uri, String[], String, String[], String)
     * ContentProvider.query()}.
     *
     * @param uri A content URI returned by {@link #getUriForFile}.
     * @param projection The list of columns to put into the {@link Cursor}. If null all columns are
     * included.
     * @param selection Selection criteria to apply. If null then all data that matches the content
     * URI is returned.
     * @param selectionArgs An array of {@link java.lang.String}, containing arguments to bind to
     * the <i>selection</i> parameter. The <i>query</i> method scans <i>selection</i> from left to
     * right and iterates through <i>selectionArgs</i>, replacing the current "?" character in
     * <i>selection</i> with the value at the current position in <i>selectionArgs</i>. The
     * values are bound to <i>selection</i> as {@link java.lang.String} values.
     * @param sortOrder A {@link java.lang.String} containing the column name(s) on which to sort
     * the resulting {@link Cursor}.
     * @return A {@link Cursor} containing the results of the query.
     *
     */
Use a content URI returned by
#getUriForFile(Context, String, File) getUriForFile() to get information about a file
managed by the FileProvider.

@param uri A content URI returned by  #getUriForFile.
@param projection The list of columns to put into the  Cursor. If null all columns are
included.
@param selection Selection criteria to apply. If null then all data that matches the content
URI is returned.
@param selectionArgs An array of  java.lang.String, containing arguments to bind to
the selection parameter. The query method scans selection from left to
right and iterates through selectionArgs, replacing the current "?" character in
selection with the value at the current position in selectionArgs. The
values are bound to selection as  java.lang.String values.
@param sortOrder A  java.lang.String containing the column name(s) on which to sort
the resulting  Cursor.
@return A  Cursor containing the results of the query.
Use a content URI returned by #getUriForFile ( Context String File ) getUriForFile () to get information about a file managed by the FileProvider . @param uri A content URI returned by #getUriForFile . @param projection The list of columns to put into the Cursor . If null all columns are included . @param selection Selection criteria to apply . If null then all data that matches the content URI is returned . @param selectionArgs An array of java . lang . String containing arguments to bind to the selection parameter . The query method scans selection from left to right and iterates through selectionArgs replacing the current " ? " character in selection with the value at the current position in selectionArgs . The values are bound to selection as java . lang . String values . @param sortOrder A java . lang . String containing the column name ( s ) on which to sort the resulting Cursor . @return A Cursor containing the results of the query .
@Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
            @Nullable String[] selectionArgs,
            @Nullable String sortOrder) {
        final File file = mStrategy.getFileForUri(uri);
        if (projection == null) {
            projection = COLUMNS;
        }
        String[] cols = new String[projection.length];
        Object[] values = new Object[projection.length];
        int i = 0;
        for (String col : projection) {
            if (OpenableColumns.DISPLAY_NAME.equals(col)) {
                cols[i] = OpenableColumns.DISPLAY_NAME;
                values[i++] = file.getName();
            } else if (OpenableColumns.SIZE.equals(col)) {
                cols[i] = OpenableColumns.SIZE;
                values[i++] = file.length();
            }
        }
        cols = copyOf(cols, i);
        values = copyOf(values, i);
        final MatrixCursor cursor = new MatrixCursor(cols, 1);
        cursor.addRow(values);
        return cursor;
    }
@ Override public Cursor query ( @ NonNull Uri uri , @ Nullable String [ ] projection , @ Nullable String selection , @ Nullable String [ ] selectionArgs , @ Nullable String sortOrder ) { final File file = mStrategy . getFileForUri ( uri ) ; if ( projection == null ) { projection = COLUMNS ; } String [ ] cols = new String [ projection . length ] ; Object [ ] values = new Object [ projection . length ] ; int i = 0 ; for ( String col : projection ) { if ( OpenableColumns . DISPLAY_NAME . equals ( col ) ) { cols [ i ] = OpenableColumns . DISPLAY_NAME ; values [ i ++ ] = file . getName ( ) ; } else if ( OpenableColumns . SIZE . equals ( col ) ) { cols [ i ] = OpenableColumns . SIZE ; values [ i ++ ] = file . length ( ) ; } } cols = copyOf ( cols , i ) ; values = copyOf ( values , i ) ; final MatrixCursor cursor = new MatrixCursor ( cols , 1 ) ; cursor . addRow ( values ) ; return cursor ; }
Use a content URI returned by
 {@link #getUriForFile(Context, String, File) getUriForFile()} to get information about a file
 managed by the FileProvider.
Use a content URI returned by { @link #getUriForFile ( Context String File ) getUriForFile () } to get information about a file managed by the FileProvider .
// ContentProvider has already checked granted permissions