Java Code Examples for android.database.MatrixCursor#newRow()

The following examples show how to use android.database.MatrixCursor#newRow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalStorageProvider.java    From droidddle with Apache License 2.0 6 votes vote down vote up
private void includeFile(final MatrixCursor result, final File file) throws FileNotFoundException {
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    String mimeType = getDocumentType(file.getAbsolutePath());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE : 0;
    // We only show thumbnails for image files - expect a call to
    // openDocumentThumbnail for each file that has
    // this flag set
    if (mimeType.startsWith("image/"))
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    row.add(Document.COLUMN_FLAGS, flags);
    // COLUMN_SIZE is required, but can be null
    row.add(Document.COLUMN_SIZE, file.length());
    // These columns are optional
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    // Document.COLUMN_ICON can be a resource id identifying a custom icon.
    // The system provides default icons
    // based on mime type
    // Document.COLUMN_SUMMARY is optional additional information about the
    // file
}
 
Example 2
Source File: LocalStorageProvider.java    From Readily with MIT License 6 votes vote down vote up
private void includeFile(final MatrixCursor result, final File file)
        throws FileNotFoundException {
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    String mimeType = getDocumentType(file.getAbsolutePath());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE
            : 0;
    // We only show thumbnails for image files - expect a call to
    // openDocumentThumbnail for each file that has
    // this flag set
    if (mimeType.startsWith("image/"))
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    row.add(Document.COLUMN_FLAGS, flags);
    // COLUMN_SIZE is required, but can be null
    row.add(Document.COLUMN_SIZE, file.length());
    // These columns are optional
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    // Document.COLUMN_ICON can be a resource id identifying a custom icon.
    // The system provides default icons
    // based on mime type
    // Document.COLUMN_SUMMARY is optional additional information about the
    // file
}
 
Example 3
Source File: LocalStorageProvider.java    From secrecy with Apache License 2.0 6 votes vote down vote up
private void includeFile(final MatrixCursor result, final File file)
        throws FileNotFoundException {
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    String mimeType = getDocumentType(file.getAbsolutePath());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE
            : 0;
    // We only show thumbnails for image files - expect a call to
    // openDocumentThumbnail for each file that has
    // this flag set
    if (mimeType.startsWith("image/"))
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    row.add(Document.COLUMN_FLAGS, flags);
    // COLUMN_SIZE is required, but can be null
    row.add(Document.COLUMN_SIZE, file.length());
    // These columns are optional
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    // Document.COLUMN_ICON can be a resource id identifying a custom icon.
    // The system provides default icons
    // based on mime type
    // Document.COLUMN_SUMMARY is optional additional information about the
    // file
}
 
Example 4
Source File: AppStorageProvider.java    From JPPF with Apache License 2.0 6 votes vote down vote up
/**
 * Add a row in the specified cursor for the specified file.
 * @param child the file for which to add a row.
 * @param cursor the cursor to add a row to.
 */
private void createRowForChild(File child, MatrixCursor cursor) {
  MatrixCursor.RowBuilder row = cursor.newRow();
  String type = getContext().getContentResolver().getType(Uri.fromFile(child));
  Log.v(LOG_TAG, "createRowForChild(child=" + child + ") type=" + type);
  if (type == null) type = child.isDirectory() ? Document.MIME_TYPE_DIR : "application/octet-stream";
  int flags = child.isDirectory()
    ? /*Document.FLAG_DIR_PREFERS_GRID |*/ Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_DIR_SUPPORTS_CREATE
    : /*Document.FLAG_SUPPORTS_WRITE*/ 0;
  row.add(Document.COLUMN_FLAGS, flags);
  row.add(Document.COLUMN_DISPLAY_NAME, child.getName());
  row.add(Document.COLUMN_DOCUMENT_ID, getDocumentId(child));
  row.add(Document.COLUMN_MIME_TYPE, type);
  row.add(Document.COLUMN_SIZE, child.isDirectory() ? child.getTotalSpace() - child.getFreeSpace() : child.length());
  row.add(Document.COLUMN_LAST_MODIFIED, null);
}
 
Example 5
Source File: LocalStorageProvider.java    From droid-stealth with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection
            : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
Example 6
Source File: LocalStorageProvider.java    From filechooser with MIT License 6 votes vote down vote up
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection
            : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
Example 7
Source File: LocalStorageProvider.java    From qiniu-lab-android with MIT License 6 votes vote down vote up
private void includeFile(final MatrixCursor result, final File file)
        throws FileNotFoundException {
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    String mimeType = getDocumentType(file.getAbsolutePath());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE
            : 0;
    // We only show thumbnails for image files - expect a call to
    // openDocumentThumbnail for each file that has
    // this flag set
    if (mimeType.startsWith("image/"))
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    row.add(Document.COLUMN_FLAGS, flags);
    // COLUMN_SIZE is required, but can be null
    row.add(Document.COLUMN_SIZE, file.length());
    // These columns are optional
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    // Document.COLUMN_ICON can be a resource id identifying a custom icon.
    // The system provides default icons
    // based on mime type
    // Document.COLUMN_SUMMARY is optional additional information about the
    // file
}
 
Example 8
Source File: StickerContentProvider.java    From flutter_whatsapp_stickers with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NonNull
private MatrixCursor getStickerPackInfo(@NonNull final Uri uri, @NonNull final List<StickerPack> stickerPackList) {
    final MatrixCursor cursor = new MatrixCursor(new String[] { STICKER_PACK_IDENTIFIER_IN_QUERY,
            STICKER_PACK_NAME_IN_QUERY, STICKER_PACK_PUBLISHER_IN_QUERY, STICKER_PACK_ICON_IN_QUERY,
            ANDROID_APP_DOWNLOAD_LINK_IN_QUERY, IOS_APP_DOWNLOAD_LINK_IN_QUERY, PUBLISHER_EMAIL, PUBLISHER_WEBSITE,
            PRIVACY_POLICY_WEBSITE, LICENSE_AGREEMENT_WEBSITE, IMAGE_DATA_VERSION, AVOID_CACHE, });

    for (final StickerPack stickerPack : stickerPackList) {
        final MatrixCursor.RowBuilder builder = cursor.newRow();
        builder.add(stickerPack.identifier);
        builder.add(stickerPack.name);
        builder.add(stickerPack.publisher);
        builder.add(stickerPack.trayImageFile);
        builder.add(stickerPack.androidPlayStoreLink);
        builder.add(stickerPack.iosAppStoreLink);
        builder.add(stickerPack.publisherEmail);
        builder.add(stickerPack.publisherWebsite);
        builder.add(stickerPack.privacyPolicyWebsite);
        builder.add(stickerPack.licenseAgreementWebsite);
        builder.add(stickerPack.imageDataVersion);
        builder.add(stickerPack.avoidCache ? 1 : 0);
    }

    cursor.setNotificationUri(Objects.requireNonNull(getContext()).getContentResolver(), uri);
    return cursor;
}
 
Example 9
Source File: LocalStorageProvider.java    From qiniu-lab-android with MIT License 6 votes vote down vote up
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection
            : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
Example 10
Source File: RecordedProgramTest.java    From xipl with Apache License 2.0 5 votes vote down vote up
private static MatrixCursor getRecordedProgramCursor(ContentValues contentValues) {
    String[] rows = RecordedProgram.PROJECTION;
    MatrixCursor cursor = new MatrixCursor(rows);
    MatrixCursor.RowBuilder builder = cursor.newRow();
    for (String row : rows) {
        builder.add(row, contentValues.get(row));
    }
    cursor.moveToFirst();
    return cursor;
}
 
Example 11
Source File: TGAssetsProvider.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
	MatrixCursor result = new MatrixCursor(this.resolveProjection(projection, DEFAULT_ROOT_PROJECTION));
	MatrixCursor.RowBuilder row = result.newRow();

	row.add(DocumentsContract.Root.COLUMN_ROOT_ID, ROOT_ID);
	row.add(DocumentsContract.Root.COLUMN_SUMMARY, getContext().getString(R.string.storage_saf_assets_provider_title));
	row.add(DocumentsContract.Root.COLUMN_FLAGS, DocumentsContract.Root.FLAG_SUPPORTS_RECENTS | DocumentsContract.Root.FLAG_SUPPORTS_SEARCH);
	row.add(DocumentsContract.Root.COLUMN_TITLE, getContext().getString(R.string.storage_saf_assets_provider_title));
	row.add(DocumentsContract.Root.COLUMN_DOCUMENT_ID, ROOT_ID);

	return result;
}
 
Example 12
Source File: ChannelTest.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
private static MatrixCursor getChannelCursor(ContentValues contentValues) {
    String[] rows = Channel.PROJECTION;
    MatrixCursor cursor = new MatrixCursor(rows);
    MatrixCursor.RowBuilder builder = cursor.newRow();
    for(String row: rows) {
        if (row != null) {
            builder.add(row, contentValues.get(row));
        }
    }
    cursor.moveToFirst();
    return cursor;
}
 
Example 13
Source File: ProgramTest.java    From xipl with Apache License 2.0 5 votes vote down vote up
private static MatrixCursor getProgramCursor(ContentValues contentValues) {
    String[] rows = Program.PROJECTION;
    MatrixCursor cursor = new MatrixCursor(rows);
    MatrixCursor.RowBuilder builder = cursor.newRow();
    for(String row: rows) {
        if (row != null) {
            builder.add(row, contentValues.get(row));
        }
    }
    cursor.moveToFirst();
    return cursor;
}
 
Example 14
Source File: RecordedProgramTest.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
private static MatrixCursor getRecordedProgramCursor(ContentValues contentValues) {
    String[] rows = RecordedProgram.PROJECTION;
    MatrixCursor cursor = new MatrixCursor(rows);
    MatrixCursor.RowBuilder builder = cursor.newRow();
    for (String row : rows) {
        builder.add(row, contentValues.get(row));
    }
    cursor.moveToFirst();
    return cursor;
}
 
Example 15
Source File: TGAssetsProvider.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void createFileRow(MatrixCursor result, String documentId) {
	MatrixCursor.RowBuilder row = result.newRow();

	row.add(DocumentsContract.Document.COLUMN_DOCUMENT_ID, documentId);
	row.add(DocumentsContract.Document.COLUMN_DISPLAY_NAME, this.getDocumentName(documentId));
	row.add(DocumentsContract.Document.COLUMN_MIME_TYPE, this.getMimeType(documentId));
}
 
Example 16
Source File: ImageProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Add a representation of a file to a cursor.
 *
 * @param result the cursor to modify
 * @param file   the File object representing the desired file (may be null if given docID)
 */
private void includeFile(MatrixCursor result, File file) {
    MatrixCursor.RowBuilder row = result.newRow();
    row.add(ImageContract.Columns.DISPLAY_NAME, file.getName());
    row.add(ImageContract.Columns.SIZE, file.length());
    row.add(ImageContract.Columns.ABSOLUTE_PATH, file.getAbsolutePath());
}
 
Example 17
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 4 votes vote down vote up
/**
 * Add a representation of a file to a cursor.
 *
 * @param result the cursor to modify
 * @param docId  the document ID representing the desired file (may be null if given file)
 * @param file   the File object representing the desired file (may be null if given docID)
 * @throws java.io.FileNotFoundException
 */
private void includeFile(MatrixCursor result, String docId, File file)
        throws FileNotFoundException {
    if (docId == null) {
        docId = getDocIdForFile(file);
    } else {
        file = getFileForDocId(docId);
    }

    int flags = 0;

    if (file.isDirectory()) {
        // Request the folder to lay out as a grid rather than a list. This also allows a larger
        // thumbnail to be displayed for each image.
        //            flags |= Document.FLAG_DIR_PREFERS_GRID;

        // Add FLAG_DIR_SUPPORTS_CREATE if the file is a writable directory.
        if (file.isDirectory() && file.canWrite()) {
            flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
        }
    } else if (file.canWrite()) {
        // If the file is writable set FLAG_SUPPORTS_WRITE and
        // FLAG_SUPPORTS_DELETE
        flags |= Document.FLAG_SUPPORTS_WRITE;
        flags |= Document.FLAG_SUPPORTS_DELETE;
    }

    final String displayName = file.getName();
    final String mimeType = getTypeForFile(file);

    if (mimeType.startsWith("image/")) {
        // Allow the image to be represented by a thumbnail rather than an icon
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    }

    final MatrixCursor.RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, displayName);
    row.add(Document.COLUMN_SIZE, file.length());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    row.add(Document.COLUMN_FLAGS, flags);

    // Add a custom icon
    row.add(Document.COLUMN_ICON, R.drawable.ic_launcher);
}
 
Example 18
Source File: ChromeFileProvider.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    Uri fileUri = getFileUriWhenReady(uri);
    if (fileUri == null) return null;

    // Workaround for a bad assumption that particular MediaStore columns exist by certain third
    // party applications.
    // http://crbug.com/467423.
    Cursor source = super.query(fileUri, projection, selection, selectionArgs, sortOrder);

    String[] columnNames = source.getColumnNames();
    String[] newColumnNames = columnNamesWithData(columnNames);
    if (columnNames == newColumnNames) return source;

    MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount());

    source.moveToPosition(-1);
    while (source.moveToNext()) {
        MatrixCursor.RowBuilder row = cursor.newRow();
        for (int i = 0; i < columnNames.length; i++) {
            switch (source.getType(i)) {
                case Cursor.FIELD_TYPE_INTEGER:
                    row.add(source.getInt(i));
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    row.add(source.getFloat(i));
                    break;
                case Cursor.FIELD_TYPE_STRING:
                    row.add(source.getString(i));
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    row.add(source.getBlob(i));
                    break;
                case Cursor.FIELD_TYPE_NULL:
                default:
                    row.add(null);
                    break;
            }
        }
    }

    source.close();
    return cursor;
}
 
Example 19
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Add a representation of a file to a cursor.
 *
 * @param result the cursor to modify
 * @param docId  the document ID representing the desired file (may be null if given file)
 * @param file   the File object representing the desired file (may be null if given docID)
 * @throws java.io.FileNotFoundException
 */
private void includeFile(MatrixCursor result, String docId, File file)
        throws FileNotFoundException {
    if (docId == null) {
        docId = getDocIdForFile(file);
    } else {
        file = getFileForDocId(docId);
    }

    int flags = 0;

    if (file.isDirectory()) {
        // Request the folder to lay out as a grid rather than a list. This also allows a larger
        // thumbnail to be displayed for each image.
        //            flags |= Document.FLAG_DIR_PREFERS_GRID;

        // Add FLAG_DIR_SUPPORTS_CREATE if the file is a writable directory.
        if (file.isDirectory() && file.canWrite()) {
            flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
        }
    } else if (file.canWrite()) {
        // If the file is writable set FLAG_SUPPORTS_WRITE and
        // FLAG_SUPPORTS_DELETE
        flags |= Document.FLAG_SUPPORTS_WRITE;
        flags |= Document.FLAG_SUPPORTS_DELETE;
    }

    final String displayName = file.getName();
    final String mimeType = getTypeForFile(file);

    if (mimeType.startsWith("image/")) {
        // Allow the image to be represented by a thumbnail rather than an icon
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    }

    final MatrixCursor.RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, displayName);
    row.add(Document.COLUMN_SIZE, file.length());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    row.add(Document.COLUMN_FLAGS, flags);

    // Add a custom icon
    row.add(Document.COLUMN_ICON, R.drawable.ic_launcher);
}
 
Example 20
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 4 votes vote down vote up
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    Log.v(TAG, "queryRoots");

    // Create a cursor with either the requested fields, or the default projection.  This
    // cursor is returned to the Android system picker UI and used to display all roots from
    // this provider.
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));

    // If user is not logged in, return an empty root cursor.  This removes our provider from
    // the list entirely.
    if (!isUserLoggedIn()) {
        return result;
    }

    // It's possible to have multiple roots (e.g. for multiple accounts in the same app) -
    // just add multiple cursor rows.
    // Construct one row for a root called "MyCloud".
    final MatrixCursor.RowBuilder row = result.newRow();

    row.add(Root.COLUMN_ROOT_ID, ROOT);
    row.add(Root.COLUMN_SUMMARY, getContext().getString(R.string.root_summary));

    // FLAG_SUPPORTS_CREATE means at least one directory under the root supports creating
    // documents.  FLAG_SUPPORTS_RECENTS means your application's most recently used
    // documents will show up in the "Recents" category.  FLAG_SUPPORTS_SEARCH allows users
    // to search all documents the application shares.
    row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE |
            Root.FLAG_SUPPORTS_RECENTS |
            Root.FLAG_SUPPORTS_SEARCH);

    // COLUMN_TITLE is the root title (e.g. what will be displayed to identify your provider).
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.app_name));

    // This document id must be unique within this provider and consistent across time.  The
    // system picker UI may save it and refer to it later.
    row.add(Root.COLUMN_DOCUMENT_ID, getDocIdForFile(mBaseDir));

    // The child MIME types are used to filter the roots and only present to the user roots
    // that contain the desired type somewhere in their file hierarchy.
    row.add(Root.COLUMN_MIME_TYPES, getChildMimeTypes(mBaseDir));
    row.add(Root.COLUMN_AVAILABLE_BYTES, mBaseDir.getFreeSpace());
    row.add(Root.COLUMN_ICON, R.drawable.ic_launcher);

    return result;
}