Search code examples
androiduriandroid-contentprovider

UriMatcher match 'n' path segments


I have a custom ContentProvider that does background processing for a ShareActionProvider. The Path of the Uri provided is a full file path (ex: /mnt/sdcard/my.file). The uri is created as such:

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

A uri match is described as:

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

Now this works for:

content://AUTHORITY/my.file

but it does not work for a full path. Is there a way to match any number of path segments?


Solution

  • I used the uri fragment instead:

    content://AUTHORITY/file.ext#/full/path/to/file.ext
    

    You can grab the full path with:

    uri.getFragment()