How to get metadata from files or folders in Google Drive on Android?
According to Working with File and Folder Metadata:
Metadata is encapsulated in the Metadata class and contains all details about a file or folder including the title, the MIME type, and whether the file is editable, starred or trashed. The metadata is fetched for a DriveResource by calling the DriveResource.getMetadata method.
Here's a snippet from the docs:
/**
* An activity to retrieve the metadata of a file.
*/
public class RetrieveMetadataActivity extends BaseDemoActivity implements
ResultCallback {
@Override
public void onConnected(Bundle connectionHint) {
DriveFile file = Drive.DriveApi.getFile(getGoogleApiClient(),
DriveId.decodeFromString("0ByfSjdPVs9MZcEE3bzJCc3NsRkE"));
file.getMetadata(getGoogleApiClient()).setResultCallback(metadataRetrievedCallback);
}
ResultCallback<MetadataResult> metadataRetrievedCallback = new
ResultCallback<MetadataResult>() {
@Override
public void onResult(MetadataResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Problem while trying to fetch metadata");
return;
}
Metadata metadata = result.getMetadata();
showMessage("Metadata succesfully fetched. Title: " + metadata.getTitle());
}
}
}
How to get resource ID?
Still on the Android API for Drive, DriveId class has a method getResourceId () which returns the resource ID.
How to get device ID?
I don't think you can use the Android Drive API to get this. It seems you've mistaken this for fileID which you'll be using to Download Files.
Locate fileID manually in Google Drive:
If it's a spreadSheet file
https://docs.google.com/spreadsheets/d/1pE9ejBTBH38oCoOHU2O42qU6vzxagAJ9J1237dYB1Eg/edit#gid=0
fileID -> 1pE9ejBTBH38oCoOHU2O42qU6vzxagAJ9J1237dYB1Eg
If it's a doc file:
https://docs.google.com/document/d/1Fh6s7an-7I6VuDBxZKcxcaU3cG1XpSryHQXGnznWlns/edit
fileID -> 1Fh6s7an-7I6VuDBxZKcxcaU3cG1XpSryHQXGnznWlns
You get the pattern. It's a string of alphanumeric characters in the URL.