2017-09-23 14 views

答えて

1

はここQuerying for Files

You can use the com.google.android.gms.drive.query package to search a user's Drive account for files whose metadata match your search criteria. You can issue a query for a specific folder or on the entire filesystem.

Note: The Android Drive API only works with the https://www.googleapis.com/auth/drive.file scope. This means that only files which a user has opened or created with your application can be matched by a query.

のドキュメントでクエリーを構築するための一例です。

A query is created by building an instance of the Query class and specifying the search criteria with Filters . The following example finds all files with the title "HelloWorld.java".

Query query = new Query.Builder() 
     .addFilter(Filters.eq(SearchableField.TITLE, "HelloWorld.java")) 
     .build(); 

You can use the Filters class to build expressions. Multiple filters can be joined together using the and and or methods.

Once a Query object has been constructed it can be executed on the entire file system using Drive.DriveApi as follows:

Drive.DriveApi.query(googleApiClient, query); 

This query starts in the My Drive (the root) folder and recursively traverse the entire filesystem, returning all entries matching the Filters expression tree.

A query can alternatively be executed only in a specific folder using an instance of the DriveFolder class, as shown by:

DriveFolder folder= ...; 
folder.query(query); 

This call does not scan recursively; only direct entries in this folder matching filter conditions are returned.

関連する問題