当前位置: 首页>>代码示例>>C#>>正文


C# ContentValues.Put方法代码示例

本文整理汇总了C#中Android.Content.ContentValues.Put方法的典型用法代码示例。如果您正苦于以下问题:C# ContentValues.Put方法的具体用法?C# ContentValues.Put怎么用?C# ContentValues.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Content.ContentValues的用法示例。


在下文中一共展示了ContentValues.Put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create your application here
            SetContentView (Resource.Layout.QuestionnaireSummary);
            int Ergebnis = Intent.GetIntExtra ("ergebnis", 0);

            TextView ErgebnisText = FindViewById<TextView> (Resource.Id.textView3);
            ErgebnisText.Text = string.Format ("{0} {1}", Resources.GetText (Resource.String.total_score), Ergebnis);

            Button ContinueHome = FindViewById<Button> (Resource.Id.button1);
            ContinueHome.Click += delegate {
                //create an intent to go to the next screen
                Intent intent = new Intent(this, typeof(Home));
                intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen
                StartActivity(intent);
            };

            //Toast.MakeText (this, string.Format ("{0}", DateTime.Now.ToString("dd.MM.yy HH:mm")), ToastLength.Short).Show();

            ContentValues insertValues = new ContentValues();
            insertValues.Put("date_time", DateTime.Now.ToString("dd.MM.yy HH:mm"));
            insertValues.Put("ergebnis", Ergebnis);
            dbRUOK = new RUOKDatabase(this);
            dbRUOK.WritableDatabase.Insert ("RUOKData", null, insertValues);

            //The following two function were used to understand the usage of SQLite. They are not needed anymore and I just keep them in case I wanna later look back at them.
            //InitializeSQLite3(Ergebnis);
            //ReadOutDB ();
        }
开发者ID:fsoyka,项目名称:RUOK,代码行数:31,代码来源:QuestionnaireSummary.cs

示例2: OnProgressChanged

        public override void OnProgressChanged(WebView view, int newProgress)
        {
            base.OnProgressChanged(view, newProgress);

            _context.SetProgress(newProgress * 100);

            if (newProgress == 100)
            {
                _context.Title = view.Title;

                bool soundEnabled = PreferenceManager.GetDefaultSharedPreferences(_context.ApplicationContext).GetBoolean("sounds", false);

                if (soundEnabled)
                {
                    _mediaPlayer = MediaPlayer.Create(_context.ApplicationContext, Resource.Raw.inception_horn);
                    _mediaPlayer.Completion += delegate { _mediaPlayer.Release(); };
                    _mediaPlayer.Start();
                }

                // add this page to the history
                using (SQLiteDatabase db = _historyDataHelper.WritableDatabase)
                {
                    var values = new ContentValues();
                    values.Put("Title", view.Title);
                    values.Put("Url", view.Url);
                    values.Put("Timestamp", DateTime.Now.Ticks);

                    db.Insert("history", null, values);
                }
            }
            else
            {
                _context.Title = _context.ApplicationContext.Resources.GetString(Resource.String.title_loading);
            }
        }
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:35,代码来源:CustomWebChromeClient.cs

示例3: AddAppointment

        //android.permission.WRITE_CALENDAR


        public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status)
        {
            ContentValues eventValues = new ContentValues();

            eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
            //_calId);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, subject);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, details);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, startTime.ToUniversalTime().ToString());
            // GetDateTimeMS(2011, 12, 15, 10, 0));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, endTime.ToUniversalTime().ToString());
            // GetDateTimeMS(2011, 12, 15, 11, 0));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Availability, ConvertAppointmentStatus(status));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, location);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, (isAllDay) ? "1" : "0");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1");

            var eventUri = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
            long eventID = long.Parse(eventUri.LastPathSegment);
            ContentValues remindervalues = new ContentValues();
            remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, ConvertReminder(reminder));
            remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID);
            remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert);
            var reminderURI = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, remindervalues);

        }
开发者ID:pedroccrl,项目名称:Xamarin.Plugins-1,代码行数:31,代码来源:CalendarConnector.cs

示例4: PerformAction

        public override void PerformAction(View view)
        {
            try
            {
                ContentValues eventValues = new ContentValues();

                eventValues.Put( CalendarContract.Events.InterfaceConsts.CalendarId,
                    _calId);
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Title,
                    "Test Event from M4A");
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Description,
                    "This is an event created from Xamarin.Android");
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart,
                    GetDateTimeMS(2011, 12, 15, 10, 0));
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend,
                    GetDateTimeMS(2011, 12, 15, 11, 0));

                var uri = ContentResolver.Insert(CalendarContract.Events.ContentUri,
                    eventValues);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, Context);

            }
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:26,代码来源:AddEventToCalAction.cs

示例5: SharePhoto

    private void SharePhoto()
    {
      var share = new Intent(Intent.ActionSend);
      share.SetType("image/jpeg");

      var values = new ContentValues();
      values.Put(MediaStore.Images.ImageColumns.Title, "title");
      values.Put(MediaStore.Images.ImageColumns.MimeType, "image/jpeg");
      Uri uri = ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, values);


      Stream outstream;
      try
      {
        
        outstream = ContentResolver.OpenOutputStream(uri);
        finalBitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, outstream);
        outstream.Close();
      }
      catch (Exception e)
      {

      }
      share.PutExtra(Intent.ExtraStream, uri);
      share.PutExtra(Intent.ExtraText, "Sharing some images from android!");
      StartActivity(Intent.CreateChooser(share, "Share Image"));
    }
开发者ID:nagyist,项目名称:FlashCastPhotoApp-Android,代码行数:27,代码来源:Activity1.cs

示例6: addGroup

        private bool addGroup()
        {
            bool result = false;
            try {

                string name = FindViewById<EditText>(Resource.Id.edit_group_name).Text;
                string description = FindViewById<EditText>(Resource.Id.edit_group_description).Text;
                string icon = FindViewById<EditText>(Resource.Id.edit_group_icon).Text;

                if (name.Length == 0 || description.Length == 0/* || icon.length() == 0*/)
                {
                    Toast.MakeText(this, "One or more fields are empty", ToastLength.Short).Show();
                    return false;
                }

                ContentValues values = new ContentValues();
                values.Put(YastroidOpenHelper.GROUP_NAME, name);
                values.Put(YastroidOpenHelper.GROUP_DESCRIPTION, description);
                values.Put(YastroidOpenHelper.GROUP_ICON, icon);

                database.Insert(YastroidOpenHelper.GROUP_TABLE_NAME, "null", values);
                database.Close();
                Log.Info("addGroup", name + " group has been added.");
                result = true;
            } catch (Exception e) {
                Log.Error("addGroup", e.Message);
            }
            Toast.MakeText(this, "Group Added", ToastLength.Short).Show();
            return result;
        }
开发者ID:decriptor,项目名称:yastroid,代码行数:30,代码来源:GroupAddActivity.cs

示例7: AddNote

        public long AddNote(string title, string contents)
        {
            var values = new ContentValues();
            values.Put("Title", title);
            values.Put("Contents", contents);

            return _helper.WritableDatabase.Insert("Note", null, values);
        }
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:8,代码来源:StandardNoteRepository.cs

示例8: CreateNote

        /// <summary>
        /// Create a new note using the title and body provided. If the note is
        /// successfully created return the new rowId for that note, otherwise return
        /// a -1 to indicate failure.
        /// </summary>
        /// <param name="title">the title of the note</param>
        /// <param name="body">the body of the note</param>
        /// <returns>rowId or -1 if failed</returns>
        public long CreateNote(string title, string body)
        {
            var initialValues = new ContentValues();
            initialValues.Put(KeyTitle, title);
            initialValues.Put(KeyBody, body);

            return this.db.Insert(DatabaseTable, null, initialValues);
        }
开发者ID:rudini,项目名称:monodroid-samples,代码行数:16,代码来源:NotesDbAdapter.cs

示例9: putRecord

        public void putRecord(long time, String difficulty, Context context)
        {
            dbHelper = new DBHelper(context);
            ContentValues cv = new ContentValues();
            SQLiteDatabase db = dbHelper.WritableDatabase;
            SQLiteCursor c = (SQLiteCursor)db.Query("records", null, " difficulty = ?", new String[]{difficulty}, null, null, null);
            int count = 1;
            if (c.MoveToFirst()) {

                int idColIndex = c.GetColumnIndex("id");
                int timeColIndex = c.GetColumnIndex("time");

                int maxDBindex = c.GetInt(idColIndex);
                int maxDBtime = c.GetInt(timeColIndex);
                count++;
                while (c.MoveToNext()) {
                    if (c.GetInt(timeColIndex) > maxDBtime){
                        maxDBtime = c.GetInt(timeColIndex);
                        maxDBindex = c.GetInt(idColIndex);
                    }
                    count++;
                }
                if (count == 6){
                    if (time < maxDBtime){
                        db.Delete("records", " id = ?", new String[]{maxDBindex + ""});
                    } else {
                        c.Close();
                        db.Close();
                        return;
                    }
                }
            }
            cv.Put("time", time);
            cv.Put("difficulty", difficulty);
            db.Insert("records", null, cv);
            cv.Clear();

            SQLiteCursor gc = (SQLiteCursor)db.Query("general", null, "difficulty = ?", new String[]{difficulty}, null, null, null);
            gc.MoveToFirst();
            int avgTimeColIndex = gc.GetColumnIndex("avgTime");
            int gamesCountColIndex = gc.GetColumnIndex("gamesCount");
            int avgTime = 0;
            int gamesCount = 0;
            if (gc.MoveToFirst()){
                avgTime = gc.GetInt(avgTimeColIndex);
                gamesCount = gc.GetInt(gamesCountColIndex);
            }
            int newGamesCount = gamesCount + 1;
            int newAvgTime = (avgTime * gamesCount / newGamesCount) + (int)(time / newGamesCount);
            cv.Put("difficulty", difficulty);
            cv.Put("avgTime", newAvgTime);
            cv.Put("gamesCount", newGamesCount);
            db.Delete("general", " difficulty = ?", new String[]{difficulty});
            db.Insert("general", null, cv);
            db.Close();
            c.Close();
            gc.Close();
        }
开发者ID:JustLex,项目名称:CourseTask,代码行数:58,代码来源:DatabaseController.cs

示例10: Insert

 public long Insert(String battleTag, String host)
 {
     var db = dbHelper.WritableDatabase;
     var values = new ContentValues();
     values.Put(AccountsOpenHelper.FIELD_BATTLETAG, battleTag);
     values.Put(AccountsOpenHelper.FIELD_HOST, host);
     values.Put(AccountsOpenHelper.FIELD_UPDATED, DateTime.Today.ToString());
     return db.Insert(AccountsOpenHelper.TABLE_NAME, null, values);
 }
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:9,代码来源:AccountsDB.cs

示例11: Update

 public long Update(String oldBattleTag, String battleTag, String host, Action<AccountFields> action)
 {
     var db = dbHelper.WritableDatabase;
     var values = new ContentValues();
     values.Put(AccountsOpenHelper.FIELD_BATTLETAG, battleTag);
     values.Put(AccountsOpenHelper.FIELD_HOST, host);
     values.Put(AccountsOpenHelper.FIELD_UPDATED, DateTime.Today.ToString(CultureInfo.InvariantCulture));
     return db.Update(AccountsOpenHelper.TABLE_NAME, values, AccountsOpenHelper.FIELD_BATTLETAG + "=?", new[] { oldBattleTag });
 }
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:9,代码来源:AccountsDB.cs

示例12: AddScore

        public long AddScore(int scoreNumber, DateTime scoreDate, string name)
        {
            var values = new ContentValues ();
            values.Put ("ScoreNumber", scoreNumber);
            values.Put ("ScoreDate", scoreDate.ToString ());
            values.Put ("PlayerName", name);

            return scrHelp.WritableDatabase.Insert ("QuizScore", null, values);
        }
开发者ID:bny-mobile,项目名称:QuizData,代码行数:9,代码来源:ScoreCommands.cs

示例13: insert

 public void insert(Transaction transaction)
 {
     ContentValues values = new ContentValues();
     values.Put(COLUMN__ID, transaction.orderId);
     values.Put(COLUMN_PRODUCT_ID, transaction.productId);
     values.Put(COLUMN_STATE, transaction.purchaseState.ToString());
     values.Put(COLUMN_PURCHASE_TIME, transaction.purchaseTime);
     values.Put(COLUMN_DEVELOPER_PAYLOAD, transaction.developerPayload);
     mDb.Replace(TABLE_TRANSACTIONS, null /* nullColumnHack */, values);
 }
开发者ID:Ezekoka,项目名称:MonoGame-StarterKits,代码行数:10,代码来源:BillingDB.cs

示例14: AddScore

        public long AddScore(int ScoreNumber, DateTime ScoreDate, double rating, double slope)
        {
            var values = new ContentValues();
            values.Put("ScoreNumber", ScoreNumber);
            values.Put("ScoreDate", ScoreDate.ToString());
            values.Put("Rating", rating);
            values.Put("Slope", slope);

            return dbHelp.WritableDatabase.Insert("GolfScore", null, values);
        }
开发者ID:evandrojr,项目名称:Leitor,代码行数:10,代码来源:dbCommands.cs

示例15: createLocationValues

        public static ContentValues createLocationValues(string locationSetting, string cityName, double lat, double lon)
        {
            // Create a new map of values, where column names are the keys
            ContentValues locValues = new ContentValues ();
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_LOCATION_SETTING, locationSetting);
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_CITY_NAME, cityName);
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LAT, lat);
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LONG, lon);

            return locValues;
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:11,代码来源:SunshineService.cs


注:本文中的Android.Content.ContentValues.Put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。