Книга: Beginning Android
Pieces of Me
Pieces of Me
The simplified model of the construction of a content Uri
is the scheme, the namespace of data, and, optionally, the instance identifier, all separated by slashes in URL-style notation. The scheme of a content Uri is always content://
.
So, a content Uri
of content://constants/5
represents the constants instance with an identifier of 5.
The combination of the scheme and the namespace is known as the “base Uri” of a content provider, or a set of data supported by a content provider. In the previous example, content://constants
is the base Uri
for a content provider that serves up information about “constants” (in this case, physical constants).
The base Uri
can be more complicated. For example, the base Uri for contacts is content://contacts/people
, as the contacts content provider may serve up other data using other base Uri
values.
The base Uri
represents a collection of instances. The base Uri
combined with an instance identifier (e.g., 5) represents a single instance.
Most of the Android APIs expect these to be Uri
objects, though in common discussion, it is simpler to think of them as strings. The Uri.parse()
static method creates a Uri
out of the string representation.