Good morning, I'm working with the google API on Android, and I found the following code to read a text file:
private void readFile(DriveId fileDriveId) {
DriveFile file = fileDriveId.asDriveFile();
file.open(mGoogleApiClient, DriveFile.MODE_READ_ONLY, null)
.setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
@Override
public void onResult(DriveApi.DriveContentsResult result) {
if (!result.getStatus().isSuccess()) {
Log.e(TAG,"Error al abrir fichero (readFile)");
return;
}
DriveContents contents = result.getDriveContents();
BufferedReader reader =
new BufferedReader(
new InputStreamReader(contents.getInputStream()));
StringBuilder builder = new StringBuilder();
try {
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
} catch (IOException e) {
Log.e(TAG,"Error al leer fichero");
}
contents.discard(mGoogleApiClient);
Log.i(TAG, "Fichero leido: " + builder.toString());
}
});
}
I tried the code and it works, but what I need to do, is that instead of reading a text file, the code will return the bitmap of the image I want to recover
How could I do that?