Can you get a list of files from the GoogleDrive AppFolder Folder?

0

I have been testing in my app several api and its these days I have been testing the Google Drive api, the question is the following can list the files of the AppFolder folder, because the state testing and to send files perfect but to list gives me error. Thank you. MY CODE:

apiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addScope(Drive.SCOPE_APPFOLDER)
.build();



DriveFolder folder = Drive.DriveApi.getAppFolder(apiClient);

folder.listChildren(apiClient).setResultCallback(
    new ResultCallback<DriveApi.MetadataBufferResult>() {
        @Override
        public void onResult(DriveApi.MetadataBufferResult metadataBufferResult) {
            if (metadataBufferResult.getStatus().isSuccess()) {
                for(Metadata m: metadataBufferResult.getMetadataBuffer())
                    //Aqui obtengo los ficheros
                    Log.i("fichero", "Fichero: " + m.getTitle() + " [" + m.getDriveId().encodeToString() + "]");

            }
            else {
                Log.e("LOGTAG", "Error al listar carpeta");
            }
        }
    });
    
asked by PowerApp 15.11.2016 в 23:42
source

1 answer

0

This is the base code that is in the documentation of the Api Rest: link

To access certain folders that are OWNER (Owner) of the folder or group.

FileList files = driveService.files().list()
        .setSpaces("appDataFolder")
        .setFields("nextPageToken, files(id, name)")
        .setPageSize(10)
        .execute();
for(File file: files.getFiles()) {
    System.out.printf("Found file: %s (%s)\n",
            file.getName(), file.getId());
}
    
answered by 16.11.2016 в 01:25