gpt4 book ai didi

android - UriMatcher 匹配 'n' 路径段

转载 作者:行者123 更新时间:2023-11-29 01:49:47 25 4
gpt4 key购买 nike

我有一个为 ShareActionProvider 执行后台处理的自定义 ContentProvider。提供的 Uri 路径是完整的文件路径(例如:/mnt/sdcard/my.file)。 uri 是这样创建的:

content://AUTHORITY/mnt/sdcard/my.file

uri 匹配被描述为:

uriMatcher.addURI(AUTHORITY, "*", 1);

现在这适用于:

content://AUTHORITY/my.file

但它不适用于完整路径。有没有一种方法可以匹配任何 数量的路径段?

最佳答案

uriMatcher的通配符 * 一次匹配1个段,所以如果要匹配

content://AUTHORITY/mnt/sdcard/my.file

你应该使用

uriMatcher.addURI(AUTHORITY, "*/*/*", 1);

这可能不是您想要的,因为您必须知道您收到了多少段。因此,您可能应该实现自己的方式来匹配 uris 并提取所需的段(类似于 uri.getPathSegments(),并遍历段以获取路径的每个部分)。

最佳。

关于android - UriMatcher 匹配 'n' 路径段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18890995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com