Reputation: 4118
While making the code for downloading files from Google Drive, I got into a very strange problem. The files which I have uploaded manually are neither being listed nor being downloaded on Android. To confirm it further, I then uploaded the same file from the same application and found that without making any change in the code, it started coming on the list and hence downloaded.
The code I am using to listing the file is;
ArrayList<Filter> fltrs = new ArrayList<Filter>();
fltrs.add(Filters.eq(SearchableField.TRASHED, false));
if (filename != null) fltrs.add(Filters.eq(SearchableField.TITLE, filename));
fltrs.add(Filters.eq(SearchableField.MIME_TYPE, "text/csv"));
Query qry = new Query.Builder().addFilter(Filters.and(fltrs)).build();
if (mGoogleSignInAccount != null) {
Task<MetadataBuffer> queryTask = mDriveResourceClient.query(qry);
...
In addOnSuccessListener() I am opening the file like
final DriveFile file = driveId.asDriveFile();
//Open the file of Google Drive
Task<DriveContents> openFileTask = mDriveResourceClient.openFile(file, DriveFile.MODE_READ_ONLY);
Please let me know if there is any change required in my code.
While referring the documents I went through this URL https://developers.google.com/drive/android/queries
In this URL, there is a note mentioning
Note: The Android Drive API only works with the https://www.googleapis.com/auth/drive.file scope. This means that only files which a user has opened or created with your application can be matched by a query.
Does this mean that I can not open or download the manually uploaded files OR is there a way to achieve this?
Upvotes: 0
Views: 97
Reputation: 7741
If these files are not yet opened in your app. Then you cannot query it. But once you already opened/view it even though it is manually uploaded, then these files are now be searchable. So you must need to open first this manually uploaded files in order for you to query it.
Upvotes: 1