[英]How do I check if I can read a document when using ContentResolver to query a DocumentsContract Uri?
I'm using a DocumentsContract
query to try to speed up reading a folder.我正在使用
DocumentsContract
查询来尝试加快读取文件夹的速度。 I got most data but I'm struggling with the flag that tells me if I can read the document.我得到了大部分数据,但我正在努力处理告诉我是否可以阅读文档的标志。
This is the query:这是查询:
contentResolver.query(uri, arrayOf(
DocumentsContract.Document.COLUMN_DOCUMENT_ID, DocumentsContract.Document.COLUMN_DISPLAY_NAME, DocumentsContract.Document.COLUMN_MIME_TYPE, DocumentsContract.Document.COLUMN_LAST_MODIFIED, DocumentsContract.Document.COLUMN_SIZE, DocumentsContract.Document.COLUMN_FLAGS), null, null, null)
DocumentsContract.Document.COLUMN_FLAGS
has in its documentation: DocumentsContract.Document.COLUMN_FLAGS
在其文档中有:
/**
* Flags that apply to a document. This column is required.
* <p>
* Type: INTEGER (int)
*
* @see #FLAG_DIR_BLOCKS_OPEN_DOCUMENT_TREE
* @see #FLAG_DIR_PREFERS_GRID
* @see #FLAG_DIR_PREFERS_LAST_MODIFIED
* @see #FLAG_DIR_SUPPORTS_CREATE
* @see #FLAG_PARTIAL
* @see #FLAG_SUPPORTS_COPY
* @see #FLAG_SUPPORTS_DELETE
* @see #FLAG_SUPPORTS_METADATA
* @see #FLAG_SUPPORTS_MOVE
* @see #FLAG_SUPPORTS_REMOVE
* @see #FLAG_SUPPORTS_RENAME
* @see #FLAG_SUPPORTS_SETTINGS
* @see #FLAG_SUPPORTS_THUMBNAIL
* @see #FLAG_SUPPORTS_WRITE
* @see #FLAG_VIRTUAL_DOCUMENT
* @see #FLAG_WEB_LINKABLE
*/
I can see WRITE
there but what about READ
?我可以在那里看到
WRITE
但READ
呢?
val canRead = context.checkCallingUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) == PackageManager.PERMISSION_GRANTED
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.