当前位置: 首页>>代码示例>>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;未经允许,请勿转载。