本文整理汇总了C#中Android.Content.ContentValues.put方法的典型用法代码示例。如果您正苦于以下问题:C# ContentValues.put方法的具体用法?C# ContentValues.put怎么用?C# ContentValues.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.ContentValues
的用法示例。
在下文中一共展示了ContentValues.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnUpgrade
public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
TLog.d(TAG, "Upgrading database from version {0} to {1}",
oldVersion, newVersion);
ICursor notesCursor;
List<Dictionary<string, string>> db_list = new List<Dictionary<string, string>>();
notesCursor = db.Query(DB_TABLE_NOTES, COLUMNS_VERSION[oldVersion - 1], null, null, null, null, null);
notesCursor.MoveToFirst();
if (oldVersion == 1) {
// GUID and NOTE_CONTENT are not saved.
TLog.d(TAG, "Database version {0} is not supported to update, all old datas will be destroyed", oldVersion);
db.ExecSQL("DROP TABLE IF Exists notes");
onCreate(db);
return;
}
// Get old datas from the SQL
while(!notesCursor.IsAfterLast) {
Dictionary<string, string> row = new Dictionary<string, string>();
for(int i = 0; i < COLUMNS_VERSION[oldVersion - 1].Length; i++) {
row.Add (COLUMNS_VERSION[oldVersion - 1][i], notesCursor.GetString(i));
}
// create new columns
if (oldVersion <= 2) {
row.Add(Note.TAGS, "");
}
if (oldVersion <= 3) {
row.Add(Note.NOTE_CONTENT_PLAIN, stringConverter.encode(Html.FromHtml(row.get(Note.TITLE) + "\n" + row.get(Note.NOTE_CONTENT)).ToString()));
}
db_list.Add(row);
notesCursor.MoveToNext();
}
db.ExecSQL("DROP TABLE IF Exists notes");
onCreate(db);
// put rows to the database
row = new ContentValues();
for(int i = 0; i < db_list.Count; i++) {
for(int j = 0; j < COLUMNS_VERSION[newVersion - 1].Length; j++) {
row.put(COLUMNS_VERSION[newVersion - 1][j], db_list.get(i).get(COLUMNS_VERSION[newVersion - 1][j]));
}
db.Insert(DB_TABLE_NOTES, null, row);
}
}