public class ContentUris
extends Object
java.lang.Object | |
↳ | android.content.ContentUris |
适用于使用“content”(content://)方案的 Uri
对象的实用方法。
内容URI具有语法
content://authority/path/id
content:
ContentResolver.SCHEME_CONTENT
(value
content://
).
/
), that identify some subset of the provider's data. Most providers use the path part to identify individual tables. Individual segments in the path are often called "directories" although they do not refer to file directories. The right-most segment in a path is often called a "twig"
_ID
often expects the id part to be a particular value for that column.
Public constructors |
|
---|---|
ContentUris() |
Public methods |
|
---|---|
static Uri.Builder |
appendId(Uri.Builder builder, long id) 将给定的ID追加到路径的末尾。 |
static long |
parseId(Uri contentUri) 将最后一个路径段转换为长整型。 |
static Uri |
withAppendedId(Uri contentUri, long id) 将给定的ID追加到路径的末尾。 |
Inherited methods |
|
---|---|
From class java.lang.Object
|
Uri.Builder appendId (Uri.Builder builder, long id)
将给定的ID追加到路径的末尾。
Parameters | |
---|---|
builder |
Uri.Builder : to append the ID to |
id |
long : to append |
Returns | |
---|---|
Uri.Builder |
the given builder |
long parseId (Uri contentUri)
将最后一个路径段转换为长整型。
这支持ID存储在最后一个段中的内容URI的通用约定。
Parameters | |
---|---|
contentUri |
Uri
|
Returns | |
---|---|
long |
the long conversion of the last segment or -1 if the path is empty |
Throws | |
---|---|
UnsupportedOperationException |
if this isn't a hierarchical URI |
NumberFormatException |
if the last segment isn't a number |
Uri withAppendedId (Uri contentUri, long id)
将给定的ID追加到路径的末尾。
Parameters | |
---|---|
contentUri |
Uri : to start with |
id |
long : to append |
Returns | |
---|---|
Uri |
a new URI with the given ID appended to the end of the path |