如何从我的谷歌驱动器中获取文件和文件夹,以在我的应用程序中显示这些?

时间:2013-08-17 06:29:36

标签: android

这是我的代码:

private void listfiles(Drive s )throws IOException
  {
  Toast.makeText(getApplicationContext(), "Inside listfiles now", Toast.LENGTH_LONG).show();
  List<File> result = new ArrayList<File>();
    Files.List request = s.files().list();
    Toast.makeText(getApplicationContext(), "list extracted", Toast.LENGTH_LONG).show();
    do {
        try {
             Toast.makeText(getApplicationContext(), "executing", Toast.LENGTH_LONG).show();

          FileList files = request.execute();

          Toast.makeText(getApplicationContext(), "Executed", Toast.LENGTH_LONG).show();
          result.addAll(files.getItems());
          request.setPageToken(files.getNextPageToken());
        } catch (IOException e) {
            Toast.makeText(getApplicationContext(), "Inside catch", Toast.LENGTH_LONG).show();
          System.out.println("An error occurred: " + e);

          request.setPageToken(null);
        }
      } while (request.getPageToken() != null &&
               request.getPageToken().length() > 0);
}

请告诉我怎么做。我真的需要它,我已经尝试了很长时间。

0 个答案:

没有答案