use of io.realm.RealmConfiguration in project ARD by MobileApplicationsClub.
the class ARD method onCreate.
@Override
public void onCreate() {
super.onCreate();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
Realm.init(this);
final RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name(AHC.REALM_ARD_DATABASE).schemaVersion(AHC.REALM_ARD_DATABASE_SCHEMA).build();
Realm.setDefaultConfiguration(realmConfiguration);
}
use of io.realm.RealmConfiguration in project Now by XunMengWinter.
the class BaseListFragment method initRealm.
protected void initRealm() {
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();
mRealm = Realm.getInstance(realmConfiguration);
mRealmDbHelper = new RealmDbHelper(mList, mRealm, getNowRealmClass());
}
use of io.realm.RealmConfiguration in project CustomViews by AndroidStudy233.
the class RealmManager method init.
/**
* 初始化realm,比如说如果你的app在不同的账号登录同一台设备就要需要建立不同的数据库(根据名称来区分)
*
* @param realmName 数据库名称
* @param version 版本号
*/
private static void init(String realmName, int version) {
RealmConfiguration configuration = new RealmConfiguration.Builder().name(// 配置名字
realmName).encryptionKey(// 加密用字段,不是64位会报错
new byte[64]).schemaVersion(// 版本号
version).migration(new RealmMigration() {
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
MyLogUtil.debug("oldVersion: " + oldVersion);
MyLogUtil.debug("newVersion: " + newVersion);
RealmObjectSchema schema = realm.getSchema().get("Doctor");
Set<String> names = schema.getFieldNames();
if (names.contains("id"))
schema.removeField("id");
if (names.contains("name") && !schema.getPrimaryKey().equals("name")) {
schema.removePrimaryKey();
schema.addPrimaryKey("name");
}
}
}).build();
Realm.setDefaultConfiguration(configuration);
// Context.getFilesDir() 目录下的realmName.realm数据库
}
use of io.realm.RealmConfiguration in project underlx by underlx.
the class Application method initRealm.
public static void initRealm(Context context) {
// Initialize Realm. Should only be done once when the application starts.
Realm.init(context);
RealmConfiguration config = new RealmConfiguration.Builder().schemaVersion(// Must be bumped when the schema changes
8).migration(new MyMigration()).build();
Realm.setDefaultConfiguration(config);
}
use of io.realm.RealmConfiguration in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class AndroidIMSICatcherDetector method onCreate.
@Override
public void onCreate() {
instance = new WeakReference<>(this);
addModule(new AndroidLoggerModule());
addModule(OkHttpModule.withCache(this));
super.onCreate();
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this).deleteRealmIfMigrationNeeded().build();
Realm.setDefaultConfiguration(realmConfiguration);
final Realm realm = Realm.getDefaultInstance();
realm.executeTransactionAsync(new DefaultDataTransaction(), new Realm.Transaction.OnSuccess() {
@Override
public void onSuccess() {
log.debug("Loading default data successful");
realm.close();
}
}, new Realm.Transaction.OnError() {
@Override
public void onError(Throwable error) {
log.error("Error loading default data", error);
realm.close();
}
});
TinyDB.getInstance().init(getApplicationContext());
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, true);
}
Aggregations