本文整理汇总了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();
}