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


C# Realm.close方法代码示例

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


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

示例1: onCreate

		protected internal override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);
			ContentView = R.layout.activity_realm_basic_example;

			rootLayout = ((LinearLayout) findViewById(R.id.container));
			rootLayout.removeAllViews();

			// 3 versions of the databases for testing. Normally you would only have one.
			copyBundledRealmFile(this.Resources.openRawResource(R.raw.default0), "default0");
			copyBundledRealmFile(this.Resources.openRawResource(R.raw.default1), "default1");
			copyBundledRealmFile(this.Resources.openRawResource(R.raw.default2), "default2");

			// When you create a RealmConfiguration you can specify the version of the schema.
			// If the schema does not have that version a RealmMigrationNeededException will be thrown.
			RealmConfiguration config0 = (new RealmConfiguration.Builder(this)).name("default0").schemaVersion(3).build();

			// You can then manually call Realm.migrateRealm().
			Realm.migrateRealm(config0, new Migration());
			realm = Realm.getInstance(config0);
			showStatus("Default0");
			showStatus(realm);
			realm.close();

			// Or you can add the migration code to the configuration. This will run the migration code without throwing
			// a RealmMigrationNeededException.
			RealmConfiguration config1 = (new RealmConfiguration.Builder(this)).name("default1").schemaVersion(3).migration(new Migration()).build();

			realm = Realm.getInstance(config1); // Automatically run migration if needed
			showStatus("Default1");
			showStatus(realm);
			realm.close();

			// or you can set .deleteRealmIfMigrationNeeded() if you don't want to bother with migrations.
			// WARNING: This will delete all data in the Realm though.
			RealmConfiguration config2 = (new RealmConfiguration.Builder(this)).name("default2").schemaVersion(3).deleteRealmIfMigrationNeeded().build();

			realm = Realm.getInstance(config2);
			showStatus("default2");
			showStatus(realm);
			realm.close();
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:42,代码来源:MigrationExampleActivity.cs


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