GoogleApiClent _gac; // initialized elsewhere //find files, folders. ANY 'null' ARGUMENT VALUE MEANS 'any' public void findAll(String title, String mime, DriveFolder fldr) { ArrayList<Filter> fltrs = new ArrayList<Filter>(); fltrs.add(Filters.eq(SearchableField.TRASHED, false)); if (title != null) fltrs.add(Filters.eq(SearchableField.TITLE, title)); if (mime != null) fltrs.add(Filters.eq(SearchableField.MIME_TYPE, mime)); Query qry = new Query.Builder().addFilter(Filters.and(fltrs)).build(); MetadataBufferResult rslt = (fldr == null) ? Drive.DriveApi.query(_gac, qry).await() : fldr.queryChildren(_gac, qry).await(); if (rslt.getStatus().isSuccess()) { MetadataBuffer mdb = null; try { mdb = rslt.getMetadataBuffer(); if (mdb != null) { for (Metadata md : mdb) { if (md == null) continue; DriveId dId = md.getDriveId(); // here is the "Drive ID" String title = md.getTitle(); String mime = md.getMimeType(); // ... } } } finally { if (mdb != null) mdb.close(); } } }
if (md == null || !md.isDataValid()) continue; String title = md.getTitle(); DriveId driveId = md.getDriveId();
public void onResult(MetadataBufferResult rslt) { if (rslt != null && rslt.getStatus().isSuccess()) { MetadataBuffer mdb = null; try { mdb = rslt.getMetadataBuffer(); if (mdb != null ) for (Metadata md : mdb) { if (md == null || !md.isDataValid()) continue; md.getTitle(); md.getDriveId(); md.getAlternateLink(); //md.get.....(); } } finally { if (mdb != null) mdb.close(); } } }
for (Metadata md : mdb) { if (md == null || !md.isDataValid() || md.isTrashed()) continue; gfs.add(UT.newCVs(md.getTitle(), md.getDriveId().encodeToString()));