Good afternoon, in the morning I did this question and I managed to save an image. The problem that arises now, is that I need to recover the id that assigns drive to that image, there is a method that I found on the internet that gives me the id, but it is very different from the method that was given to me in my last question:
private void createFile(final String filename) {
Drive.DriveApi.newDriveContents(apiClient)
.setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
@Override
public void onResult(DriveApi.DriveContentsResult result) {
if (result.getStatus().isSuccess()) {
writeSampleText(result.getDriveContents());
MetadataChangeSet changeSet =
new MetadataChangeSet.Builder()
.setTitle(filename)
.setMimeType("text/plain")
.build();
//Opción 1: Directorio raíz
DriveFolder folder = Drive.DriveApi.getRootFolder(apiClient);
//Opción 2: Otra carpeta distinta al directorio raiz
//DriveFolder folder =
// DriveId.decodeFromString("DriveId:CAESABjKGSD6wKnM7lQoAQ==").asDriveFolder();
folder.createFile(apiClient, changeSet, result.getDriveContents())
.setResultCallback(new ResultCallback<DriveFolder.DriveFileResult>() {
@Override
public void onResult(DriveFolder.DriveFileResult result) {
if (result.getStatus().isSuccess()) {
Log.i(LOGTAG, "Fichero creado con ID = " + result.getDriveFile().getDriveId());
} else {
Log.e(LOGTAG, "Error al crear el fichero");
}
}
});
} else {
Log.e(LOGTAG, "Error al crear DriveContents");
}
}
})};
I got the example from this link . How can I get the id assigned by google drive?