本文整理匯總了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;
}
示例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);
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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());
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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
}
示例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);
}