Example #1
0
        public static UserEventInfo addNewGoal(string titleA, string descriptionA, DateTime startTimeA, DateTime endTimeA, string phoneConnection)
        {
            //TODO
            //Figure out how to access the database on a phone. This will be used instead of hmhy-global.
            // Open the connection for the query.
            SQLiteDatabase db    = SQLiteDatabase.OpenDatabase(phoneConnection, null, DatabaseOpenFlags.OpenReadwrite);
            string         query = @"INSERT INTO Goal
            Values(id, @title, @description, @startTime, @endTime, reminderId)";

            // Add the values passed in to a Content Vales
            Android.Content.ContentValues values = new Android.Content.ContentValues(5);
            values.Put("0", "0");
            values.Put("1", titleA);
            values.Put("2", descriptionA);
            values.Put("3", startTimeA.ToString());
            values.Put("4", endTimeA.ToString());
            // Execute the query to inset into the phone database.
            db.Insert(query, "id, title, goalDescription, StartTime, EndTime", values);
            // Add the goal as an event to the calendar.
            AndroidCalendar userCalendar = new AndroidCalendar();

            userCalendar.AddEvent("0", titleA, startTimeA, endTimeA, descriptionA);
            UserEventInfo info = new UserEventInfo();

            info.Id        = "0";
            info.Title     = titleA;
            info.StartDate = startTimeA;
            info.EndDate   = endTimeA;

            return(info);
        }
Example #2
0
        public void CreateEvent()
        {
            AndroidCalendar userCalendar = new AndroidCalendar();

            string[] sourceColumns =
            {
                CalendarContract.Events.InterfaceConsts.Title,
                CalendarContract.Events.InterfaceConsts.Dtstart
            };

            int[] targetResources =
            {
                Resource.Id.goalTitle,
                Resource.Id.startDate
            };

            var adapter = new SimpleCursorAdapter(this, Resource.Layout.Main, userCalendar.GetEventIcursor(userCalendar.GetEventsUri(), userCalendar.GetUserCalendarEvents(), 0), sourceColumns, targetResources);

            IListAdapter ListAdapter = adapter;
        }