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