Save file in specific folder with Google Drive SDK

后端 未结 3 1961
臣服心动
臣服心动 2020-12-16 06:27

I\'ve been trying to save a plain text file into a specific folder in Google Drive on Android.

So far using the Documentation and QuickStart Guide on Google Drive I

3条回答
  •  难免孤独
    2020-12-16 07:01

    You need to use the parent parameter to put a file in a folder using insert. More details at https://developers.google.com/drive/v2/reference/files/insert

    Something like this

    File body = new File();  
    body.setTitle(fileContent.getName());
    body.setMimeType("text/plain");
    body.setParents(Arrays.asList(new File.ParentReference().setId(parentId));  
    File file = service.files().insert(body, textContent).execute();
    

提交回复
热议问题