Android Google Drive API Deleted folder still exists in query

Google drive api does not sync immediately, That is why the deleted folders are still showing, so you have to force google drive to sync using requestSync()

A sample snippet

    private MetadataBuffer getGoogleFolders(){

        Drive.DriveApi.requestSync(mGoogleApiClient).await(); //Asynchronous request 

        CustomPropertyKey customPropertyKey = new CustomPropertyKey("App", CustomPropertyKey.PRIVATE);

        Query query = new Query.Builder().addFilter(Filters.and(
                Filters.eq(SearchableField.TITLE, "My folder"),
                Filters.eq(SearchableField.TRASHED, false),
                Filters.eq(customPropertyKey, "sampleApp"))).build();

        DriveApi.MetadataBufferResult foldersResult = Drive.DriveApi.query(mGoogleApiClient, query).await();

        if (!foldersResult.getStatus().isSuccess()) {
            Log.i(TAG,"Problem while retrieving results");
            return null;

        MetadataBuffer result = foldersResult.getMetadataBuffer();

        Log.i(TAG, "total result " +  result.getCount());
        return result;



//Synchronous request 
Drive.DriveApi.requestSync(mClient).setResultCallback(new ResultCallback<Status>() {
            public void onResult(@NonNull Status status) {

                //search query performs here 



Author: bm on June 7, 2016
Category: Android

Your comment:

Your Name


Last articles