ContentUris
public
class
ContentUris
extends Object
| java.lang.Object | |
| ↳ | android.content.ContentUris |
Utility methods useful for working with Uri objects
that use the "content" (content://) scheme.
Content URIs have the syntax
content://authority/path/id
-
content: -
The scheme portion of the URI. This is always set to
ContentResolver.SCHEME_CONTENT(valuecontent://). - authority
- A string that identifies the entire content provider. All the content URIs for the provider start with this string. To guarantee a unique authority, providers should consider using an authority that is the same as the provider class' package identifier.
- path
-
Zero or more segments, separated by a forward slash (
/), 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
-
A unique numeric identifier for a single row in the subset of data identified by the
preceding path part. Most providers recognize content URIs that contain an id part
and give them special handling. A table that contains a column named
_IDoften expects the id part to be a particular value for that column.
Summary
Public constructors | |
|---|---|
ContentUris()
|
|
Public methods | |
|---|---|
static
Uri.Builder
|
appendId(Uri.Builder builder, long id)
Appends the given ID to the end of the path. |
static
long
|
parseId(Uri contentUri)
Converts the last path segment to a long. |
static
Uri
|
withAppendedId(Uri contentUri, long id)
Appends the given ID to the end of the path. |
Inherited methods | |
|---|---|
java.lang.Object
| |
Public constructors
Public methods
appendId
Uri.Builder appendId (Uri.Builder builder, long id)
Appends the given ID to the end of the path.
| Parameters | |
|---|---|
builder |
Uri.Builder: to append the ID to |
id |
long: to append |
| Returns | |
|---|---|
Uri.Builder |
the given builder |
parseId
long parseId (Uri contentUri)
Converts the last path segment to a long.
This supports a common convention for content URIs where an ID is stored in the last segment.
| 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 |
withAppendedId
Uri withAppendedId (Uri contentUri, long id)
Appends the given ID to the end of the path.
| 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 |
Interfaces
- ClipboardManager.OnPrimaryClipChangedListener
- ComponentCallbacks
- ComponentCallbacks2
- ContentProvider.PipeDataWriter
- DialogInterface
- DialogInterface.OnCancelListener
- DialogInterface.OnClickListener
- DialogInterface.OnDismissListener
- DialogInterface.OnKeyListener
- DialogInterface.OnMultiChoiceClickListener
- DialogInterface.OnShowListener
- EntityIterator
- IntentSender.OnFinished
- Loader.OnLoadCanceledListener
- Loader.OnLoadCompleteListener
- ServiceConnection
- SharedPreferences
- SharedPreferences.Editor
- SharedPreferences.OnSharedPreferenceChangeListener
- SyncStatusObserver
Classes
- AbstractThreadedSyncAdapter
- AsyncQueryHandler
- AsyncQueryHandler.WorkerArgs
- AsyncQueryHandler.WorkerHandler
- AsyncTaskLoader
- BroadcastReceiver
- BroadcastReceiver.PendingResult
- ClipboardManager
- ClipData
- ClipData.Item
- ClipDescription
- ComponentName
- ContentProvider
- ContentProviderClient
- ContentProviderOperation
- ContentProviderOperation.Builder
- ContentProviderResult
- ContentQueryMap
- ContentResolver
- ContentUris
- ContentValues
- Context
- ContextWrapper
- CursorLoader
- Entity
- Entity.NamedContentValues
- Intent
- Intent.FilterComparison
- Intent.ShortcutIconResource
- IntentFilter
- IntentFilter.AuthorityEntry
- IntentSender
- Loader
- Loader.ForceLoadContentObserver
- MutableContextWrapper
- PeriodicSync
- QuickViewConstants
- RestrictionEntry
- RestrictionsManager
- SearchRecentSuggestionsProvider
- SyncAdapterType
- SyncContext
- SyncInfo
- SyncRequest
- SyncRequest.Builder
- SyncResult
- SyncStats
- UriMatcher
- UriPermission
Exceptions