Tabnine Logo
ContentUris.parseId
Code IndexAdd Tabnine to your IDE (free)

How to use
parseId
method
in
android.content.ContentUris

Best Java code snippets using android.content.ContentUris.parseId (Showing top 20 results out of 477)

origin: robolectric/robolectric

@Test(expected = UnsupportedOperationException.class)
public void parseIdThrowsUnsupportedException() {
 ContentUris.parseId(Uri.parse("mailto:bar@foo.com"));
}
origin: jokermonn/permissions4m

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);
origin: robolectric/robolectric

@Test public void canParseId() {
 assertThat(ContentUris.parseId(Uri.withAppendedPath(URI, "1"))).isEqualTo(1L);
 assertThat(ContentUris.parseId(URI)).isEqualTo(-1L);
}
origin: robolectric/robolectric

@Test(expected = NumberFormatException.class)
public void parseIdThrowsNumberFormatException() {
 ContentUris.parseId(Uri.withAppendedPath(URI, "bar"));
}
origin: jgilfelt/chuck

@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;
}
origin: square/picasso

long id = parseId(requestUri);
origin: curtis2/SuperVideoPlayer

result = mProvider.insert(tableUri, values);
if (result != null) {
 rowId = ContentUris.parseId(result);
 entry.mRowId = rowId;
origin: ianhanniballake/TripleSolitaire

  @Override
  protected void onInsertComplete(final int token, final Object cookie, final Uri uri) {
    gameId = ContentUris.parseId(uri);
  }
};
origin: derry/delion

/**
 * @see android.content.ContentUris#parseId(Uri)
 * @return The id from a content URI or -1 if the URI has no id or is malformed.
 */
private static long getContentUriId(Uri uri) {
  try {
    return ContentUris.parseId(uri);
  } catch (UnsupportedOperationException e) {
    return -1;
  } catch (NumberFormatException e) {
    return -1;
  }
}
origin: apsun/NekoSMS

private static int uriToNotificationId(Uri uri) {
  return (int)ContentUris.parseId(uri);
}
origin: geniusgithub/AndroidDialer

  @Nullable
  private Cursor getArchiveExistsCursor(Uri voicemailUri) {
    return mResolver.query(VoicemailArchiveContract.VoicemailArchive.CONTENT_URI,
        new String[] {VoicemailArchiveContract.VoicemailArchive._ID},
        VoicemailArchiveContract.VoicemailArchive.SERVER_ID + "="
            + ContentUris.parseId(voicemailUri),
        null,
        null);
  }
}
origin: geniusgithub/AndroidDialer

@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);
}
origin: geniusgithub/AndroidDialer

private String getSelectionWithId(String selection, Uri uri) {
  int match = mUriMatcher.match(uri);
  switch (match) {
    case VOICEMAIL_ARCHIVE_TABLE:
      return selection;
    case VOICEMAIL_ARCHIVE_TABLE_ID:
      String idStr = VoicemailArchiveContract.VoicemailArchive._ID + "=" +
          ContentUris.parseId(uri);
      return TextUtils.isEmpty(selection) ? idStr : selection + " AND " + idStr;
    default:
      throw new IllegalArgumentException("Unknown uri: " + uri);
  }
}
origin: geniusgithub/AndroidDialer

@Override
public Boolean doInBackground(Void... params) {
  Cursor cursor = mContext.getContentResolver().query(VoicemailArchive.CONTENT_URI,
      null, VoicemailArchive.SERVER_ID + "=" + ContentUris.parseId(mVoicemailUri)
      + " AND " + VoicemailArchive.ARCHIVED + "= 1", null, null);
  boolean archived = cursor != null && cursor.getCount() > 0;
  cursor.close();
  return archived;
}
origin: akueisara/android-basics-nanodegree-by-google

@Override
public int update(Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) {
  final int match = sUriMatcher.match(uri);
  switch (match) {
    case PRODUCTS:
      return updateProduct(uri, contentValues, selection, selectionArgs);
    case PRODUCT_ID:
      selection = ProductEntry._ID + "=?";
      selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
      return updateProduct(uri, contentValues, selection, selectionArgs);
    default:
      throw new IllegalArgumentException("Update is not supported for " + uri);
  }
}
origin: apsun/NekoSMS

public Uri insert(Context context, T data) {
  ContentResolver contentResolver = context.getContentResolver();
  ContentValues values = serialize(data);
  Uri uri = contentResolver.insert(getContentUri(), values);
  long id = -1;
  if (uri != null) {
    id = ContentUris.parseId(uri);
  }
  if (id < 0) {
    return null;
  } else {
    return uri;
  }
}
origin: fookwood/Launcher3

SqlArguments(Uri url, String where, String[] args) {
  if (url.getPathSegments().size() == 1) {
    this.table = url.getPathSegments().get(0);
    this.where = where;
    this.args = args;
  } else if (url.getPathSegments().size() != 2) {
    throw new IllegalArgumentException("Invalid URI: " + url);
  } else if (!TextUtils.isEmpty(where)) {
    throw new UnsupportedOperationException("WHERE clause not supported: " + url);
  } else {
    this.table = url.getPathSegments().get(0);
    this.where = "_id=" + ContentUris.parseId(url);
    this.args = null;
  }
}
origin: gumingwei/WellSwipe

SqlArguments(Uri url, String where, String[] args) {
  if (url.getPathSegments().size() == 1) {
    this.table = url.getPathSegments().get(0);
    this.where = where;
    this.args = args;
  } else if (url.getPathSegments().size() != 2) {
    throw new IllegalArgumentException("Invalid URI: " + url);
  } else if (!TextUtils.isEmpty(where)) {
    throw new UnsupportedOperationException("WHERE clause not supported: " + url);
  } else {
    this.table = url.getPathSegments().get(0);
    this.where = "_id=" + ContentUris.parseId(url);
    this.args = null;
  }
}
origin: robotoworks/mechanoid

/**
 * <p>Like {@link #insert()} with the option to enable/disable change notification.</p>
 * @param notifyChange Whether to notify observers, default is true
 * @return the <b>id</b> of the record, the id property of this active record
 * will also be updated
 */
public long insert(boolean notifyChange) {
  AbstractValuesBuilder builder = createBuilder();
  
  Uri uri = builder.insert(notifyChange);
  mId = ContentUris.parseId(uri);
  
  makeDirty(false);
  
  return mId;
}
origin: robotoworks/mechanoid

@Override
public int delete(MechanoidContentProvider provider, Uri uri, String selection, String[] selectionArgs){
  final SQLiteDatabase db = provider.getOpenHelper().getWritableDatabase();
  
  if(mForUrisWithId) {
    long id = ContentUris.parseId(uri);
    int affected = SQuery.newQuery()
        .expr(BaseColumns._ID, SQuery.Op.EQ, id)
        .append(selection, selectionArgs)
        .delete(db, mSource);
    
    return affected;
    
  } else {
    return db.delete(mSource, selection, selectionArgs);
  }
}

android.contentContentUrisparseId

Popular methods of ContentUris

  • withAppendedId
  • appendId

Popular in Java

  • Running tasks concurrently on multiple threads
  • setRequestProperty (URLConnection)
  • getContentResolver (Context)
  • runOnUiThread (Activity)
  • Kernel (java.awt.image)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JFileChooser (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now