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


Java RealmMigration类代码示例

本文整理汇总了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);
}
 
开发者ID:Zhuinden,项目名称:realm-helpers,代码行数:23,代码来源:CustomApplication.java

示例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);
}
 
开发者ID:eneim,项目名称:Project-Chao,代码行数:24,代码来源:Chao.java

示例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);
}
 
开发者ID:HotBitmapGG,项目名称:MoeQuest,代码行数:24,代码来源:MoeQuestApp.java

示例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);
}
 
开发者ID:rebus007,项目名称:Git-Chat,代码行数:18,代码来源:GitChatApplication.java

示例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);
    }
 
开发者ID:Jusenr,项目名称:androidgithub,代码行数:14,代码来源:DBManager.java

示例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 ==> 重复初始化!");
        }
    }
 
开发者ID:coder173025,项目名称:MagicCube,代码行数:43,代码来源:DBHelper.java

示例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();
}
 
开发者ID:coderswithoutborders,项目名称:deglancer,代码行数:16,代码来源:DataModule.java

示例8: getMigration

import io.realm.RealmMigration; //导入依赖的package包/类
public static RealmMigration getMigration() {
    return migration;
}
 
开发者ID:dasmikko,项目名称:facepunchdroid,代码行数:4,代码来源:MainMigration.java


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