Ejemplo n.º 1
0
 @Override
 public int delete(Uri uri, String selection, String[] selectionArgs) {
   final SQLiteDatabase db = dbHelper.getWritableDatabase();
   final SelectionBuilder builder = buildSelectionFromUri(uri);
   int count = builder.where(selection, selectionArgs).delete(db);
   getContext().getContentResolver().notifyChange(uri, null);
   return count;
 }
Ejemplo n.º 2
0
  @Override
  public Uri insert(Uri uri, ContentValues contentValues) {
    Log.d(
        "MobileOrg/../OrgProvider",
        "Inserting to URI: " + uri + "  contentValues = " + contentValues);
    final String tableName = getTableNameFromUri(uri);

    if (contentValues == null) contentValues = new ContentValues();

    SQLiteDatabase db = dbHelper.getWritableDatabase();
    long rowId = db.insert(tableName, null, contentValues);

    if (rowId > 0) {
      Uri noteUri = ContentUris.withAppendedId(uri, rowId);
      getContext().getContentResolver().notifyChange(noteUri, null);
      return noteUri;
    } else throw new SQLException("Failed to insert row into " + uri);
  }
Ejemplo n.º 3
0
 @Override
 public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
   Log.d(
       "MobileOrg/../OrgProvider",
       "Updating URI: "
           + uri
           + "  values = "
           + values
           + " selection: "
           + selection
           + " selectionArgs = "
           + selectionArgs);
   final SQLiteDatabase db = dbHelper.getWritableDatabase();
   final SelectionBuilder builder = buildSelectionFromUri(uri);
   int count = builder.where(selection, selectionArgs).update(db, values);
   getContext().getContentResolver().notifyChange(uri, null);
   return count;
 }