本文整理匯總了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;
}