如何创建谷歌驱动器上的空文件夹?
问题描述:
我想创建空的文件夹,我的Android应用程序。
I am trying to create empty folder for my android app..
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();
这似乎没有工作......
This doesnt seem to work.....
获取异常:
java.io.FileNotFoundException:/标题打开失败ENOENT(没有这样的文件或目录)
java.io.FileNotFoundException:/title open failed ENOENT ( no such file or directory)
致:libcore.io.ErrnoException:打开失败:ENOENT(没有这样的文件或目录)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (no such file or directory)
答
解决...
File body = new File();
body.setTitle("title");
body.setMimeType("application/vnd.google-apps.folder");
File file = service.files().insert(body).execute();
这将创建一个名为标题在谷歌驱动器文件夹。
It will create folder named title in google drive.