Google Drive Android API List Files

168 views Asked by At

Hi i am trying to get a list of files in my google drive.

I got this method from the google developers page, but it keeps giving me the same error, a similar method is used in some of the online examples but relies on the execute method call.

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() <--- Cannot resolve method execute;

    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

There are 1 answers

0
Maclaren On BEST ANSWER

I solved my error by importing all the libraries provided in the google SDK folder.

This file can be found here: https://developers.google.com/api-client-library/java/apis/drive/v2