本文整理汇总了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);
}