i need to access the google drive storage of logged in user. For now i can fetch his name and his Email, Cover picture and Avatar. I can even ask for accessing the drive storage. But i can't get it managed to create files/folders on Gdrive.
The developers page is giving me this code to create folder: https://developers.google.com/drive/v3/web/folder
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 i am sure it can't just be that easy.
fileMetadata.setName
can not be resolved for me. I am sure i am missing something.
This is what i do while loading my GoogleApiClient
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API, Plus.PlusOptions.builder().build())
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
I don't want to use hidden app folder, instead, i want that user see the app folder, and could easy see what's inside. I have a button, and when user click on it, specific file that is saved locally should be uploaded to drive. Later on i will add maybe auto sync, but for now manual upload would be enough to understand. Thanks!!!
Any help is welcome.
In Drive API for Android, note that working with folders has slight differences when compared to Google Drive API. Folders in the Drive API for Android are specialized resources within metadata
and a DriveId
and to create a folder, call DriveFolder.createFolder
for the root folder. Then, pass the metadata containing the title and other attributes to set the values for the folder.
For a full working example, see the CreateFolderActivity sample in the Google Drive Android API Demos app.