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


Java RealmConfiguration类代码示例

本文整理汇总了Java中io.realm.RealmConfiguration的典型用法代码示例。如果您正苦于以下问题:Java RealmConfiguration类的具体用法?Java RealmConfiguration怎么用?Java RealmConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RealmConfiguration类属于io.realm包,在下文中一共展示了RealmConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRealm

import io.realm.RealmConfiguration; //导入依赖的package包/类
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;
}
 
开发者ID:xizzhu,项目名称:stetho-realm,代码行数:17,代码来源:Database.java

示例2: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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);
}
 
开发者ID:Zhuinden,项目名称:xkcd-example,代码行数:17,代码来源:CustomApplication.java

示例3: before

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RunInLooperThread.java

示例4: after

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:TestRealmConfigurationFactory.java

示例5: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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);
}
 
开发者ID:killnono,项目名称:Dalaran,代码行数:19,代码来源:XApplication.java

示例6: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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();
        }

    }
 
开发者ID:nyangate,项目名称:Crypto-Assistant,代码行数:27,代码来源:CryptoAssistant.java

示例7: logoutRealmUser

import io.realm.RealmConfiguration; //导入依赖的package包/类
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;
    }
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:23,代码来源:WEApplication.java

示例8: callWithLock

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:OsObjectStoreTests.java

示例9: before

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RealmInsertBenchmark.java

示例10: provideRealmConfiguration

import io.realm.RealmConfiguration; //导入依赖的package包/类
@Provides
public RealmConfiguration provideRealmConfiguration(Context context) {
    return new RealmConfiguration.Builder()
            .name(RealmConstants.DB_NAME)
            .schemaVersion(RealmConstants.DB_VERSION)
            .deleteRealmIfMigrationNeeded()
            .build();
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:9,代码来源:DataModule.java

示例11: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:CustomApplication.java

示例12: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();

    Realm.init(this);
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(config);
}
 
开发者ID:SimonCherryGZ,项目名称:face-landmark-android,代码行数:12,代码来源:MyApplication.java

示例13: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Realm.init(this);
    RealmConfiguration configuration = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
    Realm.setDefaultConfiguration(configuration);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:MyApplication.java

示例14: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:MyApplication.java

示例15: onCreate

import io.realm.RealmConfiguration; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:NewsReaderApplication.java


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