对于Drive.Files.List类型,方法execute()未定义

时间:2014-08-13 18:25:05

标签: android google-drive-api google-drive-android-api

我刚刚开始使用google驱动程序API for java,我使用与网站上描述相同的代码从Google驱动器检索文件列表,但方法execute不存在:(我该怎么办?< / p>

  private static List<File> retrieveAllFiles(Drive service) throws IOException {
        List<File> result = new ArrayList<File>();
        Files.List request = service.files().list();

        do {
          try {
            FileList files = request.execute(); //The method execute() is undefined for the type Drive.Files.List

            result.addAll(files.getItems());
            request.setPageToken(files.getNextPageToken());
          } catch (IOException e) {
            System.out.println("An error occurred: " + e);
            request.setPageToken(null);
          }
        } while (request.getPageToken() != null &&
                 request.getPageToken().length() > 0);

        return result;
      }

1 个答案:

答案 0 :(得分:0)

我在旅途中,所以我无法对其进行阐述。所以,我很快就切断了一段我认识有用的代码。

com.google.api.services.drive.Drive _svc;
...
com.google.api.services.drive.Drive.Files.List qry = 
                               _svc.files().list().setQ("trashed = false");
String npTok = null;
do {
  com.google.api.services.drive.model.FileList gLst = qry.execute();
  for (com.google.api.services.drive.model.File gFl : gLst.getItems()) { 
    String id = gFl.getId();
  }
  npTok = gLst.getNextPageToken();
  qry.setPageToken(npTok);
} while (npTok != null && npTok.length() > 0);
祝你好运。