Hide

SortableMetadataField

public interface SortableMetadataField implements MetadataField<T>
com.google.android.gms.drive.metadata.SortableMetadataField<T>

Interface for metadata fields that can be used to sort results of the file queries. Implementation of this interface (such as the static values in SortableField) can be add sorting criteria for the file or folder queries.

For example, the following code will find all files that are starred, have the MIME type type "text/plain" and list them in the order they were created:

 Filter starredFilter = Filters.eq(SearchableField.STARRED, true);
 Filter mimeTypeFilter = Filters.eq(SearchableField.MIME_TYPE, "text/plain");
 Query query = new Query.Builder()
                        .addFilters(starredFilter, mimeTypeFilter)
                        .addSortAscending(SortableField.CREATED_DATE)
                        .build();
 for (Metadata metadata : Drive.DriveApi.query(apiClient, query).await().getMetadataBuffer()) {
     System.out.println(metadata.getTitle());
 }