I'm trying to get a specific file by its name using the following code, however, it looks like the selection arguments are ignored as it always returns the 1st file of the root tree
final ContentResolver resolver = mContext.getContentResolver();
final Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(mUri, DocumentsContract.getDocumentId(mUri));
Cursor c = null;
try {
c = resolver.query(childrenUri, new String[] { DocumentsContract.Document.COLUMN_DOCUMENT_ID }, DocumentsContract.Document.COLUMN_DISPLAY_NAME + " = ?", new String[] { displayName }, null);
if (c.moveToFirst()) {
final String documentId = c.getString(0);
final DocumentFile result = new TreeDocumentFile(this, mContext, DocumentsContract.buildDocumentUriUsingTree(mUri, documentId));
return result;
}
} catch (Exception e) {
Log.w(TAG, "Failed query: " + e);
} finally {
closeQuietly(c);
}
Basically the result is the same that the following query
c = resolver.query(childrenUri, new String[] { DocumentsContract.Document.COLUMN_DOCUMENT_ID }, null. null, null);
Any idea why?