且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Android 上获取所有文件夹 google drive api

更新时间:2023-02-14 13:00:37

根据设计,GDAA 仅支持FILE 范围,即它将仅查找/列出 Android 应用创建的文件夹/文件.

By design, GDAA supports only the FILE scope, i.e. it will find / list only folders / files created by the Android app.

有两种解决方法:

  1. 使用 GDAA 的 intents 之一,基本上让用户选择文件/文件夹.这样,您的应用就可以使用它.
  2. 使用不同的 API,即 REST Api,它支持 DRIVE 范围,为您的应用提供完整的一组文件/文件夹.
  1. Use one of the intents of the GDAA, basically letting the user pick the file / folder. That way it will become available to your app.
  2. Use a different API, the REST Api, which supports the DRIVE scope, giving your app full set of files / folders.

如果您想研究这两个 API 的行为方式,我在 Github 上放了两个不同的演示(RESTGDAA CRUD 演示包装器).

In case you want to study how the two APIs behave, I've put two different demos on the Github (the REST and the GDAA CRUD demo wrappers).

您问题的第二部分没有答案.您不设置应用程序文件夹,您只能获取它的 DriveFolder id.您可以使用它来创建/检索对象.

The second part of your question does not have answer. You don't set the app folder, you can only get it's DriveFolder id. You use it to create / retrieve objects.

  DriveFolder appFldr = Drive.DriveApi.getAppFolder(mGooleApiClient);
  appFldr.createFile(...);
  appFldr.createFolder(...);
  appFldr.listChildren(...);
  appFldr.queryChildren(...);

...并且不要忘记添加 SCOPE_APPFOLDER 范围

... and don't forget to add the SCOPE_APPFOLDER scope

祝你好运