Save file in specific folder with Google Drive SDK

后端 未结 3 1952
臣服心动
臣服心动 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 06:57

    Step1 : Create a folder

    File body1 = new File();
    body1.setTitle("cloudbox");
    body1.setMimeType("application/vnd.google-apps.folder");
    File file1 = service.files().insert(body1).execute();
    

    Step2 : Insert your file

    File body2 = new File();  
    body2.setTitle(fileContent.getName());
    body2.setMimeType("text/plain");
    body2.setParents(Arrays.asList(new ParentReference().setId(file1.getId())));  
    File file2 = service.files().insert(body2, mediaContent).execute();
    

提交回复
热议问题