Udostępnij za pośrednictwem


ContentResolver.Canonicalize(Uri) Method

Definition

Transform the given <var>url</var> to a canonical representation of its referenced resource, which can be used across devices, persisted, backed up and restored, etc.

[Android.Runtime.Register("canonicalize", "(Landroid/net/Uri;)Landroid/net/Uri;", "")]
public Android.Net.Uri? Canonicalize (Android.Net.Uri url);
[<Android.Runtime.Register("canonicalize", "(Landroid/net/Uri;)Landroid/net/Uri;", "")>]
member this.Canonicalize : Android.Net.Uri -> Android.Net.Uri

Parameters

url
Uri

The Uri that is to be transformed to a canonical representation. Like all resolver calls, the input can be either a non-canonical or canonical Uri.

Returns

Uri

Returns the official canonical representation of <var>url</var>, or null if the content provider does not support a canonical representation of the given Uri. Many providers may not support canonicalization of some or all of their Uris.

Attributes

Remarks

Transform the given <var>url</var> to a canonical representation of its referenced resource, which can be used across devices, persisted, backed up and restored, etc. The returned Uri is still a fully capable Uri for use with its content provider, allowing you to do all of the same content provider operations as with the original Uri -- #query, #openInputStream(android.net.Uri), etc. The only difference in behavior between the original and new Uris is that the content provider may need to do some additional work at each call using it to resolve it to the correct resource, especially if the canonical Uri has been moved to a different environment.

If you are moving a canonical Uri between environments, you should perform another call to #canonicalize with that original Uri to re-canonicalize it for the current environment. Alternatively, you may want to use #uncanonicalize to transform it to a non-canonical Uri that works only in the current environment but potentially more efficiently than the canonical representation.

Java documentation for android.content.ContentResolver.canonicalize(android.net.Uri).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also