本文整理匯總了Java中io.realm.Realm.deleteRealm方法的典型用法代碼示例。如果您正苦於以下問題:Java Realm.deleteRealm方法的具體用法?Java Realm.deleteRealm怎麽用?Java Realm.deleteRealm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.realm.Realm
的用法示例。
在下文中一共展示了Realm.deleteRealm方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: after
import io.realm.Realm; //導入方法依賴的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();
}
}
示例2: before
import io.realm.Realm; //導入方法依賴的package包/類
@BeforeExperiment
public void before() {
Realm.init(InstrumentationRegistry.getTargetContext());
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.deleteRealm(config);
realm = Realm.getInstance(config);
realm.beginTransaction();
for (int i = 0; i < DATA_SIZE; i++) {
AllTypes obj = realm.createObject(AllTypes.class);
obj.setColumnLong(i);
obj.setColumnBoolean(i % 2 == 0);
obj.setColumnString("Foo " + i);
obj.setColumnDouble(i + 1.234D);
}
realm.commitTransaction();
results = realm.where(AllTypes.class).findAll();
}
示例3: before
import io.realm.Realm; //導入方法依賴的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();
}
示例4: onCreate
import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
application = this;
Nammu.init(this);
/*
* Configure Realm
*/
Realm.init(this);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(realmConfiguration);
try {
DataStore.getInstance();
} catch (RealmError e) {
Log.e(TAG, "Error configuring realm, deleting and trying again.", e);
Realm.deleteRealm(realmConfiguration);
DataStore.getInstance();
}
}
示例5: tryRealmStorage
import io.realm.Realm; //導入方法依賴的package包/類
private static boolean tryRealmStorage(File path) {
// check where we can actually store the databases on this device
RealmConfiguration realmTestConfiguration;
// catch all errors when creating directory and db
try {
realmTestConfiguration = new RealmConfiguration.Builder()
.directory(path)
.name("test_storage.realm")
.deleteRealmIfMigrationNeeded()
.build();
Realm testInstance = Realm.getInstance(realmTestConfiguration);
testInstance.close();
Realm.deleteRealm(realmTestConfiguration);
} catch (Throwable e) {
Log.i(LOG_ID, "Test creation of realm failed for: '" + path.toString() + "': " + e.toString());
return false;
}
return true;
}
示例6: Zoo
import io.realm.Realm; //導入方法依賴的package包/類
public Zoo() {
realmConfig = new RealmConfiguration.Builder() // The app is responsible for calling `Realm.init(Context)`
.name("library.zoo.realm") // So always use a unique name
.modules(new AllAnimalsModule()) // Always use explicit modules in library projects
.build();
// Reset Realm
Realm.deleteRealm(realmConfig);
}
示例7: onCreate
import io.realm.Realm; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_realm_example);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();
Realm.deleteRealm(realmConfiguration);
realm = Realm.getInstance(realmConfiguration);
}
示例8: onCreate
import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.deleteRealm(config);
Realm.setDefaultConfiguration(config);
createTestData();
}
示例9: deleteBlog
import io.realm.Realm; //導入方法依賴的package包/類
public static void deleteBlog(@NonNull String blogUrl) {
RealmResults<BlogMetadata> matchingBlogs = findAllBlogsMatchingUrl(blogUrl);
if (matchingBlogs.isEmpty()) {
throw new IllegalStateException("No blog found matching the URL: " + blogUrl);
}
// we don't allow adding more than 1 blog with the same URL, so this should never happen
if (matchingBlogs.size() > 1) {
throw new IllegalStateException("More than 1 blog found matching the URL: " + blogUrl);
}
// delete blog metadata before data because data without metadata is harmless, but vice-versa is not
// keep a copy of the metadata around so we can delete the data Realm after this
final Realm realm = Realm.getDefaultInstance();
BlogMetadata blogToDelete = matchingBlogs.get(0);
RealmConfiguration dataRealmToDelete = realm.copyFromRealm(blogToDelete).getDataRealmConfig();
RealmUtils.executeTransaction(realm, r -> {
RealmObject.deleteFromRealm(blogToDelete);
});
// delete blog data
Realm.deleteRealm(dataRealmToDelete);
// if the active blog was deleted, set the active blog to a different one
if (blogUrl.equals(getActiveBlogUrl())) {
List<BlogMetadata> allBlogs = getAllBlogs();
if (!allBlogs.isEmpty()) {
setActiveBlog(allBlogs.get(0).getBlogUrl());
} else {
setActiveBlog("");
}
}
}
示例10: onCreate
import io.realm.Realm; //導入方法依賴的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
}
示例11: before
import io.realm.Realm; //導入方法依賴的package包/類
@BeforeExperiment
public void before() {
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.deleteRealm(config);
realm = Realm.getInstance(config);
realm.beginTransaction();
writeObject = realm.createObject(AllTypes.class);
}
示例12: before
import io.realm.Realm; //導入方法依賴的package包/類
@BeforeExperiment
public void before() {
RealmConfiguration config = new RealmConfiguration.Builder().build();
Realm.deleteRealm(config);
realm = Realm.getInstance(config);
realm.beginTransaction();
for (int i = 0; i < DATA_SIZE; i++) {
AllTypes obj = realm.createObject(AllTypes.class);
obj.setColumnLong(i);
obj.setColumnBoolean(i % 2 == 0);
obj.setColumnString("Foo " + i);
obj.setColumnDouble(i + 1.234D);
}
realm.commitTransaction();
}
示例13: clearCache
import io.realm.Realm; //導入方法依賴的package包/類
public void clearCache() {
RealmConfiguration config = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.directory(getCacheDir())
.build();
Realm.deleteRealm(config);
}
示例14: cleanDatabase
import io.realm.Realm; //導入方法依賴的package包/類
@Override
protected void cleanDatabase() {
mRealm.close();
Realm.deleteRealm(mRealm.getConfiguration());
mRealm = Realm.getDefaultInstance();
}
示例15: onCreate
import io.realm.Realm; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_realm_example);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();
// Clear the realm from last time
Realm.deleteRealm(realmConfiguration);
// Create a new empty instance of Realm
realm = Realm.getInstance(realmConfiguration);
}