I am integrating Drive within my app. I am able to upload and download file from Drive.
But the issue is, I am not able to identify the particular textfile exists on drive or not, when I do first time uploading.
Please some one help me with accurate solution.
Thank you
Refer this
A sample query can be built as below and we can check if the file already exists or not
class SearchFileTask extends AsyncTask<Query, Void, MetadataBufferResult>{
@Override
protected MetadataBufferResult doInBackground(Query... params) {
return Drive.DriveApi.query(getGoogleApiClient(), params[0]).await();
}
@Override
protected void onPostExecute(MetadataBufferResult metadataBufferResult) {
if(metadataBufferResult.getMetadataBuffer().getCount()==0)
// NO file
else
// File exists with given name
}
}
Query query = new Query
.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, "filename.extension"))
.build();
new SearchFileTask().execute(query);