public override int Update(Uri uri, ContentValues values, string selection, string[] selectionArgs) { if (LOGV) { Log.Verbose(TAG, "update(uri=" + uri + ", values=" + values.ToString() + ")"); } SQLiteDatabase db = mOpenHelper.WritableDatabase; SelectionBuilder builder = BuildSimpleSelection(uri); int retVal = builder.Where(selection, selectionArgs).Update(db, values); Context.ContentResolver.NotifyChange(uri, null); return(retVal); }
public override Uri Insert(Uri uri, ContentValues values) { if (LOGV) { Log.Verbose(TAG, "insert(uri=" + uri + ", values=" + values.ToString() + ")"); } SQLiteDatabase db = mOpenHelper.WritableDatabase; int match = sUriMatcher.Match(uri); switch (match) { case BLOCKS: { db.InsertOrThrow(ScheduleDatabase.Tables.BLOCKS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Blocks.BuildBlockUri(values.GetAsString(ScheduleContract.Blocks.BLOCK_ID))); } case TRACKS: { db.InsertOrThrow(ScheduleDatabase.Tables.TRACKS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Tracks.BuildTrackUri(values.GetAsString(ScheduleContract.Tracks.TRACK_ID))); } case ROOMS: { db.InsertOrThrow(ScheduleDatabase.Tables.ROOMS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Rooms.BuildRoomUri(values.GetAsString(ScheduleContract.Rooms.ROOM_ID))); } case SESSIONS: { db.InsertOrThrow(ScheduleDatabase.Tables.SESSIONS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Sessions.BuildSessionUri(values.GetAsString(ScheduleContract.Sessions.SESSION_ID))); } case SESSIONS_ID_SPEAKERS: { db.InsertOrThrow(ScheduleDatabase.Tables.SESSIONS_SPEAKERS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Speakers.BuildSpeakerUri(values.GetAsString(ScheduleDatabase.SessionsSpeakers.SPEAKER_ID))); } case SESSIONS_ID_TRACKS: { db.InsertOrThrow(ScheduleDatabase.Tables.SESSIONS_TRACKS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Tracks.BuildTrackUri(values.GetAsString(ScheduleDatabase.SessionsTracks.TRACK_ID))); } case SPEAKERS: { db.InsertOrThrow(ScheduleDatabase.Tables.SPEAKERS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Speakers.BuildSpeakerUri(values.GetAsString(ScheduleContract.Speakers.SPEAKER_ID))); } case VENDORS: { db.InsertOrThrow(ScheduleDatabase.Tables.VENDORS, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.Vendors.BuildVendorUri(values.GetAsString(ScheduleContract.Vendors.VENDOR_ID))); } case SEARCH_SUGGEST: { db.InsertOrThrow(ScheduleDatabase.Tables.SEARCH_SUGGEST, null, values); Context.ContentResolver.NotifyChange(uri, null); return(ScheduleContract.SearchSuggest.CONTENT_URI); } default: { throw new Exception("Unknown uri: " + uri); } } }