/** * This method creates a {@link Uri} for a single term, referenced by id. * @param id The id of the term. * @return The Uri with the appended id. */ public static Uri buildTermUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } }
@Test(expected = UnsupportedOperationException.class) public void parseIdThrowsUnsupportedException() { ContentUris.parseId(Uri.parse("mailto:bar@foo.com")); }
result = mProvider.insert(tableUri, values); if (result != null) { rowId = ContentUris.parseId(result); entry.mRowId = rowId; result = ContentUris.withAppendedId(tableUri, rowId); mProvider.update(result, values, null, null);
static PendingIntent getCalendarPendingIntent(Context context, int requestCode) { Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath("time"); ContentUris.appendId(builder, System.currentTimeMillis()); return PendingIntent.getActivity( context, requestCode, new Intent(Intent.ACTION_VIEW).setData(builder.build()), PendingIntent.FLAG_UPDATE_CURRENT); } }
@Nullable private Cursor getCallLogInfoCursor(Uri voicemailUri) { return mResolver.query( ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI_WITH_VOICEMAIL, ContentUris.parseId(voicemailUri)), CallLogQuery._PROJECTION, null, null, null); }
static Intent createOpenCalendarAtDayIntent(DateTime goToTime) { Intent intent = createCalendarIntent(); Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath(TIME); if (goToTime.getMillis() != 0) { intent.putExtra(KEY_DETAIL_VIEW, true); ContentUris.appendId(builder, goToTime.getMillis()); } intent.setData(builder.build()); return intent; }
/** * This method creates a {@link Uri} for a single term, referenced by id. * @param id The id of the term. * @return The Uri with the appended id. */ public static Uri buildTermUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } }
Uri rawContactUri = contentResolver.insert(ContactsContract.RawContacts .CONTENT_URI, values); long rawContactId = ContentUris.parseId(rawContactUri); values.put(ContactsContract.Contacts.Data.MIMETYPE, ContactsContract.CommonDataKinds .StructuredName.CONTENT_ITEM_TYPE);
private List<CalendarEvent> getPastEventsWithColorList() { Uri.Builder builder = Instances.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, 0); ContentUris.appendId(builder, DateUtil.now(zone).getMillis()); List<CalendarEvent> eventList = queryList(builder.build(), getPastEventsWithColorSelection()); for (CalendarEvent event : eventList) { event.setDefaultCalendarColor(); } return eventList; }
/** * This method creates a {@link Uri} for a single term, referenced by id. * @param id The id of the term. * @return The Uri with the appended id. */ public static Uri buildTermUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } }
/** * This method creates a {@link Uri} for a single term, referenced by id. * @param id The id of the term. * @return The Uri with the appended id. */ public static Uri buildTermUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } }
@Test(expected = NumberFormatException.class) public void parseIdThrowsNumberFormatException() { ContentUris.parseId(Uri.withAppendedPath(URI, "bar")); }
/** * This method creates a {@link Uri} for a single term, referenced by id. * @param id The id of the term. * @return The Uri with the appended id. */ public static Uri buildTermUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } }
@Override @Nullable public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) { SQLiteDatabase db = databaseHelper.getWritableDatabase(); Cursor cursor = null; switch (matcher.match(uri)) { case TRANSACTIONS: cursor = LocalCupboard.getInstance().withDatabase(db).query(HttpTransaction.class). withProjection(projection). withSelection(selection, selectionArgs). orderBy(sortOrder). getCursor(); break; case TRANSACTION: cursor = LocalCupboard.getInstance().withDatabase(db).query(HttpTransaction.class). byId(ContentUris.parseId(uri)). getCursor(); break; } if (cursor != null) { cursor.setNotificationUri(getContext().getContentResolver(), uri); } return cursor; }
/** * This method creates a {@link Uri} for a single term, referenced by id. * @param id The id of the term. * @return The Uri with the appended id. */ public static Uri buildTermUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } }
long id = parseId(requestUri);
public static Uri getAlbumArtUri(long albumId) { return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), albumId); } public static String getAlbumArtForFile(String filePath) {
@Override protected void onInsertComplete(final int token, final Object cookie, final Uri uri) { gameId = ContentUris.parseId(uri); } };
public static Uri getAlbumArtUri(long albumId) { return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), albumId); }