Java 类io.realm.RealmConfiguration 实例源码

项目:stetho-realm    文件:Database.java   
private synchronized SharedRealm getRealm(String path) {
    SharedRealm realm = realms.get(path);
    if (realm == null) {
        final File realmFile = new File(path);
        final RealmConfiguration.Builder builder =
            new RealmConfiguration.Builder().directory(realmFile.getParentFile())
                .name(realmFile.getName());
        final byte[] encryptionKey = encryptionKeys.get(realmFile.getName());
        if (encryptionKey != null && encryptionKey.length > 0) {
            builder.encryptionKey(encryptionKey);
        }
        realm = SharedRealm.getInstance(builder.build());
        realms.put(path, realm);
    }
    return realm;
}
项目:xkcd-example    文件:CustomApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    random = new Random();
    xkcdMapper = new XkcdMapper();
    executor = Executors.newSingleThreadExecutor();
    Realm.init(this);
    RealmConfiguration realmConfiguration = new RealmConfiguration.Builder() //
            .deleteRealmIfMigrationNeeded() //
            .build();
    Realm.setDefaultConfiguration(realmConfiguration);
    retrofit = new Retrofit.Builder().baseUrl("http://xkcd.com/")
            .addConverterFactory(LoganSquareConverterFactory.create())
            .build();
    xkcdService = retrofit.create(XkcdService.class);
}
项目:GitHub    文件:RunInLooperThread.java   
@Override
protected void before() throws Throwable {
    super.before();

    RealmConfiguration config = createConfiguration(UUID.randomUUID().toString());
    List<Object> refs = new ArrayList<>();
    List<Realm> realms = new ArrayList<>();
    List<Closeable> closeables = new ArrayList<>();

    synchronized (lock) {
        realmConfiguration = config;
        realm = null;
        backgroundHandler = null;
        keepStrongReference = refs;
        testRealms = realms;
        closableResources = closeables;
    }
}
项目:GitHub    文件:TestRealmConfigurationFactory.java   
@Override
protected void after() {
    try {
        for (RealmConfiguration configuration : configurations) {
            Realm.deleteRealm(configuration);
        }
    } catch (IllegalStateException e) {
        // Only throws the exception caused by deleting the opened Realm if the test case itself doesn't throw.
        if (!isUnitTestFailed()) {
            throw e;
        }
    } finally {
        // This will delete the temp directory.
        super.after();
    }
}
项目:Dalaran    文件:XApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    mContext = this;
    // The Realm file will be located in Context.getFilesDir() with name "default.realm"
    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(config);

    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
}
项目:Crypto-Assistant    文件:CryptoAssistant.java   
@Override
    public void onCreate() {
        super.onCreate();
        Fabric.with(this, new Crashlytics());
        Realm.init(this);
        RealmConfiguration config = new RealmConfiguration.Builder()
                .deleteRealmIfMigrationNeeded().
                        build();
        Realm.setDefaultConfiguration(config);
        FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/questrial_regular.ttf");
//        FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/quicksand_bold.ttf");
        FontsOverride.setDefaultFont(this, "SERIF", "fonts/quicksand_regular.ttf");
        FontsOverride.setDefaultFont(this, "serif", "fonts/quicksand_regular.ttf");
        FontsOverride.setDefaultFont(this, "arial", "fonts/quicksand_regular.ttf");
//        FontsOverride.setDefaultFont(this, "monospace", "fonts/quicksand_bold.ttf");
        FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/quicksand_bold.ttf");

        Logger.d("tokenized");
        try {
            Logger.d(FirebaseInstanceId.getInstance().getToken());
            setUser();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
项目:yyox    文件:WEApplication.java   
private void logoutRealmUser() {
    //注册成功写数据库
    RealmConfiguration config = new RealmConfiguration.Builder().name("yyox.realm").build();
    Realm objRealm = Realm.getInstance(config);

    //查找
    RealmUser realmUser = objRealm.where(RealmUser.class).findFirst();
    if (realmUser != null) {
        //先删除
        objRealm.beginTransaction();
        RealmResults results = objRealm.where(RealmUser.class).findAll();
        results.deleteAllFromRealm();
        objRealm.commitTransaction();
        //再添加
        objRealm.beginTransaction();
        RealmUser realmUserNew = objRealm.createObject(RealmUser.class);
        realmUserNew.setName("");
        objRealm.commitTransaction();

        mRealmUser = null;
    }
}
项目:GitHub    文件:OsObjectStoreTests.java   
@Test
public void callWithLock() {
    RealmConfiguration config = configFactory.createConfiguration();

    // Return false if there are opened OsSharedRealm instance
    OsSharedRealm sharedRealm = OsSharedRealm.getInstance(config);
    assertFalse(OsObjectStore.callWithLock(config, new Runnable() {
        @Override
        public void run() {
            fail();
        }
    }));
    sharedRealm.close();

    final AtomicBoolean callbackCalled = new AtomicBoolean(false);
    assertTrue(OsObjectStore.callWithLock(config, new Runnable() {
        @Override
        public void run() {
            callbackCalled.set(true);
        }
    }));
    assertTrue(callbackCalled.get());
}
项目:GitHub    文件:RealmInsertBenchmark.java   
@BeforeExperiment
public void before() {
    Realm.init(InstrumentationRegistry.getTargetContext());
    RealmConfiguration config = new RealmConfiguration.Builder().build();
    Realm.deleteRealm(config);
    realm = Realm.getInstance(config);

    for (int i = 0; i < COLLECTION_SIZE; i++) {
        noPkObjects.add(new AllTypes());
    }

    for (int i = 0; i < COLLECTION_SIZE; i++) {
        AllTypesPrimaryKey allTypesPrimaryKey = new AllTypesPrimaryKey();
        allTypesPrimaryKey.setColumnLong(i);
        pkObjects.add(allTypesPrimaryKey);
    }

    realm.beginTransaction();
}
项目:devsuite-android    文件:DataModule.java   
@Provides
public RealmConfiguration provideRealmConfiguration(Context context) {
    return new RealmConfiguration.Builder()
            .name(RealmConstants.DB_NAME)
            .schemaVersion(RealmConstants.DB_VERSION)
            .deleteRealmIfMigrationNeeded()
            .build();
}
项目:GitHub    文件:CustomApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    // The Realm file will be located in Context.getFilesDir() with name "default.realm"
    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder().build();
    Realm.setDefaultConfiguration(config);
}
项目:face-landmark-android    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();

    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(config);
}
项目:GitHub    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    Realm.init(this);
    RealmConfiguration configuration = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
    Realm.setDefaultConfiguration(configuration);
}
项目:GitHub    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();

    // Configure Realm for the application
    Realm.init(this);
    RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();
    Realm.deleteRealm(realmConfiguration); // Clean slate
    Realm.setDefaultConfiguration(realmConfiguration); // Make this Realm the default
}
项目:GitHub    文件:NewsReaderApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    context = this;

    initializeTimber();
    RxJavaPlugins.setErrorHandler(throwable -> Timber.e(throwable.toString()));

    // Configure default configuration for Realm
    Realm.init(this);
    RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
    Realm.setDefaultConfiguration(realmConfig);
}
项目:GitHub    文件:ProgressListenerTests.java   
private long getStoreTestDataSize(RealmConfiguration config) {
    Realm adminRealm = Realm.getInstance(config);
    long objectCounts = adminRealm.where(AllTypes.class).count();
    adminRealm.close();

    return objectCounts;
}
项目:GitHub    文件:AuthTests.java   
@Test
public void cachedInstanceShouldNotThrowIfRefreshTokenExpires() throws InterruptedException {
    String username = UUID.randomUUID().toString();
    String password = "password";

    SyncCredentials credentials = SyncCredentials.usernamePassword(username, password, true);
    final SyncUser user = spy(SyncUser.login(credentials, Constants.AUTH_URL));

    when(user.isValid()).thenReturn(true, false);

    final RealmConfiguration configuration = new SyncConfiguration.Builder(user, Constants.USER_REALM).build();
    Realm realm = Realm.getInstance(configuration);

    assertFalse(user.isValid());
    verify(user, times(2)).isValid();

    final CountDownLatch backgroundThread = new CountDownLatch(1);
    // Should not throw when using an expired refresh_token form a different thread
    // It should be able to open a Realm with an expired token
    new Thread() {
        @Override
        public void run() {
            Realm instance = Realm.getInstance(configuration);
            instance.close();
            backgroundThread.countDown();
        }
    }.start();

    backgroundThread.await();

    // It should be possible to open a cached Realm with expired token
    Realm cachedInstance = Realm.getInstance(configuration);
    assertNotNull(cachedInstance);

    realm.close();
    cachedInstance.close();
    user.logout();
}
项目:GitHub    文件:AuthTests.java   
@Test
public void usingConfigurationWithInvalidUserShouldThrow() {
    String username = UUID.randomUUID().toString();
    String password = "password";

    SyncCredentials credentials = SyncCredentials.usernamePassword(username, password, true);
    SyncUser user = SyncUser.login(credentials, Constants.AUTH_URL);
    RealmConfiguration configuration = new SyncConfiguration.Builder(user, Constants.USER_REALM).build();
    user.logout();
    assertFalse(user.isValid());
    Realm instance = Realm.getInstance(configuration);
    instance.close();
}
项目:SOS-The-Healthcare-Companion    文件:DatabaseHandler.java   
public Realm getNewRealmInstance() {
    if (mRealmConfig == null) {
        mRealmConfig = new RealmConfiguration.Builder(mContext)
                .schemaVersion(4)
                .build();
    }
    return Realm.getInstance(mRealmConfig); // Automatically run migration if needed
}
项目:GlossikaSchedule    文件:MainApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    // initialize Realm
    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .name("glossikaschedule.realm")
            .schemaVersion(1)
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(config);
}
项目:Kutuk    文件:KutukApp.java   
@Override
public void onCreate() {
    super.onCreate();
    Realm.init(this);
    RealmConfiguration.Builder config = new RealmConfiguration.Builder()
            .name("kutuk.realm")
            .schemaVersion(SCHEMA_VERSION);
    if (BuildConfig.DEBUG) {
        config.deleteRealmIfMigrationNeeded();
    } else {
        config.migration(new Migration());
    }
    Realm.setDefaultConfiguration(config.build());
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E> Observable<CollectionChange<RealmResults<E>>> changesetsFrom(Realm realm, final RealmResults<E> results) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Observable.create(new ObservableOnSubscribe<CollectionChange<RealmResults<E>>>() {
        @Override
        public void subscribe(final ObservableEmitter<CollectionChange<RealmResults<E>>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final Realm observableRealm = Realm.getInstance(realmConfig);
            resultsRefs.get().acquireReference(results);
            final OrderedRealmCollectionChangeListener<RealmResults<E>> listener = new OrderedRealmCollectionChangeListener<RealmResults<E>>() {
                @Override
                public void onChange(RealmResults<E> e, OrderedCollectionChangeSet changeSet) {
                    if (!emitter.isDisposed()) {
                        emitter.onNext(new CollectionChange<RealmResults<E>>(results, changeSet));
                    }
                }
            };
            results.addChangeListener(listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    results.removeChangeListener(listener);
                    observableRealm.close();
                    resultsRefs.get().releaseReference(results);
                }
            }));

            // Emit current value immediately
            emitter.onNext(new CollectionChange<>(results, null));
        }
    });
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E> Flowable<RealmList<E>> from(Realm realm, final RealmList<E> list) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Flowable.create(new FlowableOnSubscribe<RealmList<E>>() {
        @Override
        public void subscribe(final FlowableEmitter<RealmList<E>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final Realm observableRealm = Realm.getInstance(realmConfig);
            listRefs.get().acquireReference(list);
            final RealmChangeListener<RealmList<E>> listener = new RealmChangeListener<RealmList<E>>() {
                @Override
                public void onChange(RealmList<E> results) {
                    if (!emitter.isCancelled()) {
                        emitter.onNext(list);
                    }
                }
            };
            list.addChangeListener(listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    list.removeChangeListener(listener);
                    observableRealm.close();
                    listRefs.get().releaseReference(list);
                }
            }));

            // Emit current value immediately
            emitter.onNext(list);

        }
    }, BACK_PRESSURE_STRATEGY);
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E> Observable<CollectionChange<RealmList<E>>> changesetsFrom(Realm realm, final RealmList<E> list) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Observable.create(new ObservableOnSubscribe<CollectionChange<RealmList<E>>>() {
        @Override
        public void subscribe(final ObservableEmitter<CollectionChange<RealmList<E>>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final Realm observableRealm = Realm.getInstance(realmConfig);
            listRefs.get().acquireReference(list);
            final OrderedRealmCollectionChangeListener<RealmList<E>> listener = new OrderedRealmCollectionChangeListener<RealmList<E>>() {
                @Override
                public void onChange(RealmList<E> results, OrderedCollectionChangeSet changeSet) {
                    if (!emitter.isDisposed()) {
                        emitter.onNext(new CollectionChange<>(results, changeSet));
                    }
                }
            };
            list.addChangeListener(listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    list.removeChangeListener(listener);
                    observableRealm.close();
                    listRefs.get().releaseReference(list);
                }
            }));

            // Emit current value immediately
            emitter.onNext(new CollectionChange<>(list, null));
        }
    });
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E> Flowable<RealmList<E>> from(DynamicRealm realm, final RealmList<E> list) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Flowable.create(new FlowableOnSubscribe<RealmList<E>>() {
        @Override
        public void subscribe(final FlowableEmitter<RealmList<E>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final DynamicRealm observableRealm = DynamicRealm.getInstance(realmConfig);
            listRefs.get().acquireReference(list);
            final RealmChangeListener<RealmList<E>> listener = new RealmChangeListener<RealmList<E>>() {
                @Override
                public void onChange(RealmList<E> results) {
                    if (!emitter.isCancelled()) {
                        emitter.onNext(list);
                    }
                }
            };
            list.addChangeListener(listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    list.removeChangeListener(listener);
                    observableRealm.close();
                    listRefs.get().releaseReference(list);
                }
            }));

            // Emit current value immediately
            emitter.onNext(list);

        }
    }, BACK_PRESSURE_STRATEGY);
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E> Observable<CollectionChange<RealmList<E>>> changesetsFrom(DynamicRealm realm, final RealmList<E> list) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Observable.create(new ObservableOnSubscribe<CollectionChange<RealmList<E>>>() {
        @Override
        public void subscribe(final ObservableEmitter<CollectionChange<RealmList<E>>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final DynamicRealm observableRealm = DynamicRealm.getInstance(realmConfig);
            listRefs.get().acquireReference(list);
            final OrderedRealmCollectionChangeListener<RealmList<E>> listener = new OrderedRealmCollectionChangeListener<RealmList<E>>() {
                @Override
                public void onChange(RealmList<E> results, OrderedCollectionChangeSet changeSet) {
                    if (!emitter.isDisposed()) {
                        emitter.onNext(new CollectionChange<>(results, changeSet));
                    }
                }
            };
            list.addChangeListener(listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    list.removeChangeListener(listener);
                    observableRealm.close();
                    listRefs.get().releaseReference(list);
                }
            }));

            // Emit current value immediately
            emitter.onNext(new CollectionChange<>(list, null));
        }
    });
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E extends RealmModel> Flowable<E> from(final Realm realm, final E object) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Flowable.create(new FlowableOnSubscribe<E>() {
        @Override
        public void subscribe(final FlowableEmitter<E> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final Realm observableRealm = Realm.getInstance(realmConfig);
            objectRefs.get().acquireReference(object);
            final RealmChangeListener<E> listener = new RealmChangeListener<E>() {
                @Override
                public void onChange(E obj) {
                    if (!emitter.isCancelled()) {
                        emitter.onNext(obj);
                    }
                }
            };
            RealmObject.addChangeListener(object, listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    RealmObject.removeChangeListener(object, listener);
                    observableRealm.close();
                    objectRefs.get().releaseReference(object);
                }
            }));

            // Emit current value immediately
            emitter.onNext(object);

        }
    }, BACK_PRESSURE_STRATEGY);
}
项目:GitHub    文件:RealmObservableFactory.java   
@Override
public <E extends RealmModel> Observable<ObjectChange<E>> changesetsFrom(Realm realm, final E object) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Observable.create(new ObservableOnSubscribe<ObjectChange<E>>() {
        @Override
        public void subscribe(final ObservableEmitter<ObjectChange<E>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final Realm observableRealm = Realm.getInstance(realmConfig);
            objectRefs.get().acquireReference(object);
            final RealmObjectChangeListener<E> listener = new RealmObjectChangeListener<E>() {
                @Override
                public void onChange(E obj, ObjectChangeSet changeSet) {
                    if (!emitter.isDisposed()) {
                        emitter.onNext(new ObjectChange<>(obj, changeSet));
                    }
                }
            };
            RealmObject.addChangeListener(object, listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    RealmObject.removeChangeListener(object, listener);
                    observableRealm.close();
                    objectRefs.get().releaseReference(object);
                }
            }));

            // Emit current value immediately
            emitter.onNext(new ObjectChange<>(object, null));
        }
    });
}
项目:bikedeboa-android    文件:BikeDeBoaApplication.java   
private void initDatabase() {

        Realm.init(BikeDeBoaApplication.this);
        RealmConfiguration configuration = new RealmConfiguration.Builder()
                .deleteRealmIfMigrationNeeded()
                .build();
        Realm.setDefaultConfiguration(configuration);
    }
项目:realm-monarchy    文件:DataModule.java   
@Provides
@Singleton
Monarchy monarchy(RealmConfiguration realmConfiguration) {
    return new Monarchy.Builder() //
            .setRealmConfiguration(realmConfiguration) //
            .build();
}
项目:GitHub    文件:SyncObjectServerFacade.java   
@Override
public void realmClosed(RealmConfiguration configuration) {
    // Last Thread using the specified configuration is closed
    // delete the wrapped Java session
    if (configuration instanceof SyncConfiguration) {
        SyncConfiguration syncConfig = (SyncConfiguration) configuration;
        invokeRemoveSession(syncConfig);
    } else {
        throw new IllegalArgumentException(WRONG_TYPE_OF_CONFIGURATION);
    }
}
项目:GitHub    文件:SyncObjectServerFacade.java   
@Override
public Object[] getUserAndServerUrl(RealmConfiguration config) {
    if (config instanceof SyncConfiguration) {
        SyncConfiguration syncConfig = (SyncConfiguration) config;
        SyncUser user = syncConfig.getUser();
        String rosServerUrl = syncConfig.getServerUrl().toString();
        String rosUserIdentity = user.getIdentity();
        String syncRealmAuthUrl = user.getAuthenticationUrl().toString();
        String rosSerializedUser = user.toJson();
        byte sessionStopPolicy = syncConfig.getSessionStopPolicy().getNativeValue();
        return new Object[]{rosUserIdentity, rosServerUrl, syncRealmAuthUrl, rosSerializedUser, syncConfig.syncClientValidateSsl(), syncConfig.getServerCertificateFilePath(), sessionStopPolicy, syncConfig.isPartialRealm()};
    } else {
        return new Object[8];
    }
}
项目:GitHub    文件:SyncObjectServerFacade.java   
@Override
public String getSyncServerCertificateFilePath(RealmConfiguration configuration) {
    if (configuration instanceof SyncConfiguration) {
        SyncConfiguration syncConfig = (SyncConfiguration) configuration;
        return syncConfig.getServerCertificateFilePath();
    } else {
        throw new IllegalArgumentException(WRONG_TYPE_OF_CONFIGURATION);
    }
}
项目:realm-monarchy    文件:Monarchy.java   
/**
 * Allows to manually use Realm instance and will automatically close it when done.
 *
 * @param realmBlock the Realm execution block in which Realm should remain open
 */
public final void doWithRealm(final RealmBlock realmBlock) {
    RealmConfiguration configuration = getRealmConfiguration();
    Realm realm = null;
    try {
        realm = Realm.getInstance(configuration);
        realmBlock.doWithRealm(realm);
    } finally {
        if(realm != null) {
            realm.close();
        }
    }
}
项目:GitHub    文件:RemoteProcessService.java   
@Override
void run() {
    thiz.testRealm = Realm.getInstance(new RealmConfiguration.Builder().build());
    int expected = 1;
    long got = thiz.testRealm.where(AllTypes.class).count();
    if (expected == got) {
        response(null);
    } else {
        response(currentLine() + "expected: " + expected + ", but got " + got);
    }
    thiz.testRealm.close();
}
项目:GitHub    文件:RemoteProcessService.java   
@Override
void run() {
    thiz.testRealm = Realm.getInstance(new RealmConfiguration.Builder().build());
    thiz.testRealm.close();
    response(null);
    Runtime.getRuntime().exit(0);
}
项目:TMDB-App    文件:ApplicationController.java   
public RealmConfiguration getRealmConfig() {
    //realm migration
        if (localconfig == null) {
            localconfig = new RealmConfiguration.Builder(getContext())
                    .name("LocalDB")
                    .schemaVersion(1)
                    //.migration(new RealmMigration())
                    .deleteRealmIfMigrationNeeded()
                    .build();
        }
        return localconfig;
}
项目:Ghost-Android    文件:SpectreApplication.java   
private void setupMetadataRealm() {
    final int METADATA_DB_SCHEMA_VERSION = 4;
    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .modules(new BlogMetadataModule())
            .schemaVersion(METADATA_DB_SCHEMA_VERSION)
            .migration(new BlogMetadataDBMigration())
            .build();
    Realm.setDefaultConfiguration(config);
    AnalyticsService.logMetadataDbSchemaVersion(String.valueOf(METADATA_DB_SCHEMA_VERSION));
}
项目:GitHub    文件:RealmObjectWriteBenchmarks.java   
@BeforeExperiment
public void before() {
    RealmConfiguration config = new RealmConfiguration.Builder().build();
    Realm.deleteRealm(config);
    realm = Realm.getInstance(config);
    realm.beginTransaction();
    writeObject = realm.createObject(AllTypes.class);
}
项目:GitHub    文件:RealmAllocBenchmarks.java   
@BeforeExperiment
public void before() {
    Realm.init(InstrumentationRegistry.getTargetContext());
    RealmConfiguration config = new RealmConfiguration.Builder().build();
    Realm.deleteRealm(config);
    realm = Realm.getInstance(config);
    realm.beginTransaction();
    realm.createObject(AllTypes.class).getColumnRealmList().add(realm.createObject(AllTypes.class));
    realm.commitTransaction();
}