本文整理汇总了Java中io.realm.RealmMigration类的典型用法代码示例。如果您正苦于以下问题:Java RealmMigration类的具体用法?Java RealmMigration怎么用?Java RealmMigration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RealmMigration类属于io.realm包,在下文中一共展示了RealmMigration类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import io.realm.RealmMigration; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
Realm.setDefaultConfiguration(new RealmConfiguration.Builder().schemaVersion(7) //
.migration(new RealmMigration() {
@Override
public void migrate(@NonNull DynamicRealm realm, long oldVersion, long newVersion) {
RealmAutoMigration.migrate(realm);
}
}) //
.initialData(realm -> {
Cat cat = new Cat();
for(CatNames catName : CatNames.values()) {
cat.setName(catName.getName());
realm.insert(cat);
}
}) //
.build());
SingletonComponent singletonComponent = DaggerSingletonComponent.create();
Injector.setComponent(singletonComponent);
}
示例2: onCreate
import io.realm.RealmMigration; //导入依赖的package包/类
@Override public void onCreate() {
super.onCreate();
sInstance = this;
RealmConfiguration configuration =
new RealmConfiguration.Builder(this).deleteRealmIfMigrationNeeded()
.migration(new RealmMigration() {
@Override public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
}
})
.name("chao.realm")
.build();
Realm.setDefaultConfiguration(configuration);
Stetho.initialize(Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
示例3: onCreate
import io.realm.RealmMigration; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
mAppContext = this;
// 配置Realm数据库
RealmConfiguration configuration = new RealmConfiguration
.Builder(this)
.deleteRealmIfMigrationNeeded()
.schemaVersion(6)
.migration(new RealmMigration() {
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
}
}).build();
Realm.setDefaultConfiguration(configuration);
//配置腾讯bugly
CrashReport.initCrashReport(getApplicationContext(), ConstantUtil.BUGLY_ID, false);
}
示例4: onCreate
import io.realm.RealmMigration; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
RealmConfiguration config = new RealmConfiguration.Builder(getApplicationContext())
.name(getResources().getString(R.string.database_conf_name))
.schemaVersion(getResources().getInteger(R.integer.database_conf_version))
.modules(new DbModule())
.deleteRealmIfMigrationNeeded()
.migration(new RealmMigration() {
@Override
public void migrate(DynamicRealm dynamicRealm, long l, long l1) {
Log.d(TAG, "migrate l [" + l + "] l1 [" + l1 + "]");
}
})
.build();
Realm.setDefaultConfiguration(config);
}
示例5: initDefaultRealm
import io.realm.RealmMigration; //导入依赖的package包/类
public static void initDefaultRealm(@NonNull String dbSuffix, int version, RealmMigration realmMigration) {
Realm.removeDefaultConfiguration();
RealmConfiguration.Builder builder = new RealmConfiguration.Builder()
.name("db_realm_" + dbSuffix)
.schemaVersion(version)
.rxFactory(new RealmObservableFactory());
// .deleteRealmIfMigrationNeeded();
if (realmMigration != null)
builder.migration(realmMigration);
RealmConfiguration realmConfiguration = builder.build();
Realm.setDefaultConfiguration(realmConfiguration);
}
示例6: init
import io.realm.RealmMigration; //导入依赖的package包/类
/**
* 初始化
*/
public static void init(Context context) {
if (sInstance == null) {
if (context != null && context instanceof Application) {
sInstance = (Application) context;
/**
* 初始化Realm数据库
*/
Realm.init(context);
Realm.setDefaultConfiguration(new RealmConfiguration.Builder()
// .directory(context.getFilesDir())
// .name(Realm.DEFAULT_REALM_NAME)
// .encryptionKey(null)
.schemaVersion(4)
.migration(new RealmMigration() {
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
Log.e("Realm: migrate", "数据库迁移@oldVersion: " + oldVersion + "@newVersion: " + newVersion);
}
})
.deleteRealmIfMigrationNeeded()
.build());
Stetho.initialize(Stetho.newInitializerBuilder(context)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(context)
// .withFolder(context.getCacheDir())
// .withEncryptionKey("encrypted.realm", "MagicCube".getBytes())
// .withMetaTables()
// .withDescendingOrder()
// .withLimit(1000)
// .databaseNamePattern(Pattern.compile(".+\\.realm"))
.build())
.build());
} else {
throw new IllegalArgumentException("context is null or doesn't Application Instance!");
}
} else {
Log.e("DBHelper: init", "sInstance != null ==> 重复初始化!");
}
}
示例7: provideRealmConfiguration
import io.realm.RealmMigration; //导入依赖的package包/类
@Singleton
@Provides
RealmConfiguration provideRealmConfiguration(Context context) {
return new RealmConfiguration.Builder(context)
.name("deglancer.realm")
.schemaVersion(3)
.deleteRealmIfMigrationNeeded()
.migration(new RealmMigration() {
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
}
})
.build();
}
示例8: getMigration
import io.realm.RealmMigration; //导入依赖的package包/类
public static RealmMigration getMigration() {
return migration;
}