當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。