DocumentsProvider查询未过滤行

问题描述 投票:0回答:1

此查询不使用selectionClause过滤行(总是返回目录中的所有文件)。请帮助..

Uri treeUri  = DocumentsContract.buildTreeDocumentUri("com.android.externalstorage.documents", "primary");
Uri childUri = DocumentsContract.buildChildDocumentsUriUsingTree(treeUri, DocumentsContract.getTreeDocumentId(treeUri));

String[] columns  = {DocumentsContract.Document.COLUMN_DISPLAY_NAME};
String selections = DocumentsContract.Document.COLUMN_DISPLAY_NAME + " = 'myfile.txt'";
Cursor childCursor       = getContentResolver().query(childUri, columns, selections, null, null);

try{
    while (childCursor.moveToNext()){
        Log.d("Files = ", childCursor.getString(0));
    }
}
java android sqlite android-external-storage document-provider
1个回答
0
投票

[我认为您的问题与以下问题有关:“ FileSystemProvider不支持对子对象进行选择或对arg进行排序,它已损坏”-请参阅“ [ContentResolver Query on DocumentContract Lists all files disregarding selection”和“ https://www.reddit.com/r/androiddev/comments/b80qqt/weekly_questions_thread_april_01_2019/ek9oew6/”]

© www.soinside.com 2019 - 2024. All rights reserved.