Reputation: 79
I would like to create a folder and a file in Google Drive using Google Drive API in my Android app. I read the document and just give this code:
File fileMetadata = new File();
fileMetadata.setName("Invoices");
fileMetadata.setMimeType("application/vnd.google-apps.folder");
File file = driveService.files().create(fileMetadata)
.setFields("id")
.execute();
System.out.println("Folder ID: " + file.getId());
But the editor always wants me to create a local variable of driveService
.
what is driveService
? the quickstart document seems not a example for android?
Upvotes: 1
Views: 786
Reputation: 19339
Drive Android API is deprecated since December 2018, and you should use the REST API, which contains this quickstart.
In this case, the driveService
corresponds to an instance of Class Drive, and can be used to call the API through the Java library.
Instantiating Drive
requires you to provide credentials
. You can see a detailed example in the referenced Java quickstart (where driveService
is instead named service
), and can see the different ways of doing this, documented in the library docs: see Drive constructor and Drive.Builder.
Upvotes: 2