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


C# ContentValues.Clear方法代码示例

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


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

示例1: InsertValues

        void InsertValues()
        {
            ContentValues values = new ContentValues();

            values.Put(LocationContentProvider._ID, 1);
            values.Put(LocationContentProvider.NAME, "Brüel & Kjær");
            values.Put(LocationContentProvider.LATITUTDE, 55.816932);
            values.Put(LocationContentProvider.LONGITUDE, 12.532697);
            Android.Net.Uri uri = ContentResolver.Insert(LocationContentProvider.CONTENT_URI, values);
            System.Diagnostics.Debug.WriteLine("Insert: " + uri.ToString());

            values.Clear();

            values.Put(LocationContentProvider._ID, 2);
            values.Put(LocationContentProvider.NAME, "Technical University of Denmark");
            values.Put(LocationContentProvider.LATITUTDE, 55.786323);
            values.Put(LocationContentProvider.LONGITUDE, 12.524135);
            uri = ContentResolver.Insert(LocationContentProvider.CONTENT_URI, values);
            System.Diagnostics.Debug.WriteLine("Insert: " + uri.ToString());
        }
开发者ID:Cheesebaron,项目名称:MonoDroid.ContentProviderDemo,代码行数:20,代码来源:Activity1.cs

示例2: 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

示例3: initDB

 public void initDB(SQLiteDatabase db)
 {
     db.ExecSQL("DROP TABLE IF EXISTS " + "general");
     db.ExecSQL("DROP TABLE IF EXISTS " + "records");
     db.ExecSQL("create table records ("
         + "id integer primary key autoincrement,"
         + "time int,"
         + "difficulty text" + ");");
     db.ExecSQL("create table general ("
         + "difficulty text primary key,"
         + "avgTime int,"
         + "gamesCount int" + ");");
     ContentValues cv = new ContentValues();
     cv.Put("difficulty", "Easy");
     cv.Put("avgTime", 0);
     cv.Put("gamesCount", 0);
     db.Insert("general", null, cv);
     cv.Clear();
     cv.Put("difficulty", "Normal");
     cv.Put("avgTime", 0);
     cv.Put("gamesCount", 0);
     db.Insert("general", null, cv);
     cv.Clear();
     cv.Put("difficulty", "Hard");
     cv.Put("avgTime", 0);
     cv.Put("gamesCount", 0);
     db.Insert("general", null, cv);
 }
开发者ID:JustLex,项目名称:CourseTask,代码行数:28,代码来源:DatabaseController.cs


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