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 int Delete(Uri uri, string selection, string[] selectionArgs)
        {
            if (LOGV)
            {
                Log.Verbose(TAG, "delete(uri=" + uri + ")");
            }
            SQLiteDatabase   db      = mOpenHelper.WritableDatabase;
            SelectionBuilder builder = BuildSimpleSelection(uri);
            int retVal = builder.Where(selection, selectionArgs).Delete(db);

            Context.ContentResolver.NotifyChange(uri, null);
            return(retVal);
        }
        public override Android.Database.ICursor Query(Android.Net.Uri uri, string[] projection, string selection, string[] selectionArgs, string sortOrder)
        {
            if (LOGV)
            {
                Log.Verbose(TAG, "query(uri=" + uri + ", proj=" + projection.ToString() + ")");
            }
            SQLiteDatabase db = mOpenHelper.ReadableDatabase;

            int match = sUriMatcher.Match(uri);

            switch (match)
            {
            default: {
                // Most cases are handled with simple SelectionBuilder
                SelectionBuilder builder = BuildExpandedSelection(uri, match);
                return(builder.Where(selection, selectionArgs).Query(db, projection, sortOrder));
            }

            case SEARCH_SUGGEST: {
                SelectionBuilder builder = new SelectionBuilder();

                // Adjust incoming query to become SQL text match
                selectionArgs[0] = selectionArgs[0] + "%";
                builder.Table(ScheduleDatabase.Tables.SEARCH_SUGGEST);
                builder.Where(selection, selectionArgs);
                builder.Map(SearchManager.SuggestColumnQuery,
                            SearchManager.SuggestColumnText1);

                projection = new String[] { BaseColumns.Id, SearchManager.SuggestColumnText1,
                                            SearchManager.SuggestColumnQuery };

                String limit = uri.GetQueryParameter(SearchManager.SuggestParameterLimit);
                return(builder.Query(db, projection, null, null, ScheduleContract.SearchSuggest.DEFAULT_SORT, limit));
            }
            }
        }
Пример #4
0
		public override Android.Database.ICursor Query (Android.Net.Uri uri, string[] projection, string selection, string[] selectionArgs, string sortOrder)
		{
			if (LOGV) Log.Verbose(TAG, "query(uri=" + uri + ", proj=" + projection.ToString() + ")");
	        SQLiteDatabase db = mOpenHelper.ReadableDatabase;
	
	        int match = sUriMatcher.Match(uri);
	        switch (match) {
	            default: {
	                // Most cases are handled with simple SelectionBuilder
	                SelectionBuilder builder = BuildExpandedSelection(uri, match);
	                return builder.Where(selection, selectionArgs).Query(db, projection, sortOrder);
	            }
	            case SEARCH_SUGGEST: {
	                SelectionBuilder builder = new SelectionBuilder();
	
	                // Adjust incoming query to become SQL text match
	                selectionArgs[0] = selectionArgs[0] + "%";
	                builder.Table(ScheduleDatabase.Tables.SEARCH_SUGGEST);
	                builder.Where(selection, selectionArgs);
	                builder.Map(SearchManager.SuggestColumnQuery,
	                        SearchManager.SuggestColumnText1);
	
	                projection = new String[] { BaseColumns.Id, SearchManager.SuggestColumnText1,
	                        SearchManager.SuggestColumnQuery };
	
	                String limit = uri.GetQueryParameter(SearchManager.SuggestParameterLimit);
	                return builder.Query(db, projection, null, null, ScheduleContract.SearchSuggest.DEFAULT_SORT, limit);
	            }
	        }
		}