當前位置: 首頁>>代碼示例>>Java>>正文


Java Realm.deleteRealm方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:TestRealmConfigurationFactory.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:RealmResultsBenchmarks.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:RealmInsertBenchmark.java

示例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();
    }
}
 
開發者ID:KwalaGroup,項目名稱:Android-Client,代碼行數:27,代碼來源:KwalaApplication.java

示例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;
}
 
開發者ID:DorianScholz,項目名稱:OpenLibre,代碼行數:22,代碼來源:OpenLibre.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:Zoo.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:JsonExampleActivity.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:MyApplication.java

示例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("");
        }
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:33,代碼來源:AccountManager.java

示例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
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:MyApplication.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:RealmObjectWriteBenchmarks.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RealmQueryBenchmarks.java

示例13: clearCache

import io.realm.Realm; //導入方法依賴的package包/類
public void clearCache() {
    RealmConfiguration config = new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .directory(getCacheDir())
            .build();
    Realm.deleteRealm(config);
}
 
開發者ID:garretyoder,項目名稱:Cluttr,代碼行數:8,代碼來源:Cluttr.java

示例14: cleanDatabase

import io.realm.Realm; //導入方法依賴的package包/類
@Override
protected void cleanDatabase() {
    mRealm.close();

    Realm.deleteRealm(mRealm.getConfiguration());

    mRealm = Realm.getDefaultInstance();
}
 
開發者ID:AmeliaPessoa,項目名稱:DBPA,代碼行數:9,代碼來源:RealmDB.java

示例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);
}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:14,代碼來源:GridViewExampleActivity.java


注:本文中的io.realm.Realm.deleteRealm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。