如何在谷歌硬盘上创建空文件夹?

ano*_*ous 4 android google-drive-api

我正在尝试为我的Android应用程序创建空文件夹..

File body = new File();

body.setTitle("title");

java.io.File fileContent = new java.io.File("title");

FileContent mediaContent = new FileContent("application/vnd.google-apps.folder", fileContent);

File file = service.files().insert(body, mediaContent).execute();
Run Code Online (Sandbox Code Playgroud)

这似乎不起作用.....

获得例外:

java.io.FileNotFoundException:/ title打开失败ENOENT(没有这样的文件或目录)

引起:libcore.io.ErrnoException:打开失败:ENOENT(没有这样的文件或目录)

ano*_*ous 19

解决了...

File body = new File();
body.setTitle("title");
body.setMimeType("application/vnd.google-apps.folder");
File file = service.files().insert(body).execute();
Run Code Online (Sandbox Code Playgroud)

它将在谷歌驱动器中创建名为title的文件夹.