当前位置: 首页>>代码示例>>Java>>正文


Java Realm.close方法代码示例

本文整理汇总了Java中io.realm.Realm.close方法的典型用法代码示例。如果您正苦于以下问题:Java Realm.close方法的具体用法?Java Realm.close怎么用?Java Realm.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.realm.Realm的用法示例。


在下文中一共展示了Realm.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateRealm2

import io.realm.Realm; //导入方法依赖的package包/类
private void populateRealm2() {
    final Realm realm = Realm.getInstance(
        new RealmConfiguration.Builder().directory(new File(getFilesDir(), "custom"))
            .name("random.realm")
            .build());

    final Author moses = new Author();
    moses.name = "Moses";
    final Book genesis = new Book();
    genesis.index = 0;
    genesis.name = "Genesis";
    genesis.author = moses;
    final Verse verse =
        Verse.create(genesis, 0, 0, "In the beginning God created the heaven and the earth.");

    realm.beginTransaction();
    realm.copyToRealmOrUpdate(verse);
    realm.commitTransaction();

    realm.close();
}
 
开发者ID:xizzhu,项目名称:stetho-realm,代码行数:22,代码来源:App.java

示例2: onCreate

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    handler = new Handler(Looper.myLooper());
    final Runnable runnable = new Runnable() {
        @Override
        public void run() {
            Realm realm = Realm.getDefaultInstance();
            realm.beginTransaction();
            realm.copyToRealmOrUpdate(Utils.createStandaloneProcessInfo(AnotherProcessService.this));
            realm.commitTransaction();
            realm.close();
            handler.postDelayed(this, 1000);
        }
    };
    handler.postDelayed(runnable, 1000);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:AnotherProcessService.java

示例3: onHandleIntent

import io.realm.Realm; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getExtras() != null) {
        String personId = intent.getStringExtra("person_id");
        Realm realm = Realm.getDefaultInstance();
        Person person = realm.where(Person.class).equalTo("id", personId).findFirst();
        final String output = person.toString();
        new Handler(getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getApplicationContext(), "Loaded Person from intent service: " + output, Toast.LENGTH_LONG).show();
            }
        });
        realm.close();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ReceivingService.java

示例4: insert

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public boolean insert(TodoList todoList) {
    Realm realm = Realm.getInstance(configuration);
    final TodoListDAO dao = RealmConverter.convert(todoList);

    realm.beginTransaction();
    try {
        realm.copyToRealm(dao);
        realm.commitTransaction();
    } catch (Throwable throwable) {
        realm.cancelTransaction();
        realm.close();
        return false;
    }
    realm.close();
    return true;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:18,代码来源:TodoListRepositoryImpl.java

示例5: getHeaderById

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public Optional<TodoListHeader> getHeaderById(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    Optional<TodoListHeaderDAO> headerDAO = Optional.fromNullable(realm.where(TodoListHeaderDAO.class).equalTo("uuid", uuid).findFirst());
    Optional<TodoListHeader> header = headerDAO.transform(new TodoListHeaderDAOConverter());
    realm.close();
    return header;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:9,代码来源:TodoListRepositoryImpl.java

示例6: delete

import io.realm.Realm; //导入方法依赖的package包/类
public static <O extends  RealmObject> void delete(Realm realmInstance, QueryFilters filters, Class<O> clazz){
    Realm realm = realmInstance;
    realm.beginTransaction();
    RealmQuery<O> query = realm.where(clazz);
    query = filters.copyToRealmQuery(query);
    final RealmResults<O> results = query.findAll();
    results.deleteAllFromRealm();
    realm.commitTransaction();
    realm.close();
}
 
开发者ID:rezkyatinnov,项目名称:kyandroid,代码行数:11,代码来源:LocalData.java

示例7: usingConfigurationWithInvalidUserShouldThrow

import io.realm.Realm; //导入方法依赖的package包/类
@Test
public void usingConfigurationWithInvalidUserShouldThrow() {
    String username = UUID.randomUUID().toString();
    String password = "password";

    SyncCredentials credentials = SyncCredentials.usernamePassword(username, password, true);
    SyncUser user = SyncUser.login(credentials, Constants.AUTH_URL);
    RealmConfiguration configuration = new SyncConfiguration.Builder(user, Constants.USER_REALM).build();
    user.logout();
    assertFalse(user.isValid());
    Realm instance = Realm.getInstance(configuration);
    instance.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:AuthTests.java

示例8: savePackage

import io.realm.Realm; //导入方法依赖的package包/类
/**
 * Save a package to database.
 * @param pack The package to save. See {@link Package}
 */
@Override
public void savePackage(@NonNull Package pack) {
    Realm rlm = RealmHelper.newRealmInstance();
    // DO NOT forget begin and commit the transaction.
    rlm.beginTransaction();
    rlm.copyToRealmOrUpdate(pack);
    rlm.commitTransaction();
    rlm.close();
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:14,代码来源:PackagesLocalDataSource.java

示例9: getTodoListById

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public Optional<TodoList> getTodoListById(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    Optional<TodoListDAO> todoListDAO = Optional.fromNullable(realm.where(TodoListDAO.class).equalTo("uuid", uuid).findFirst());
    Optional<TodoList> todoList = todoListDAO.transform(new TodoListDAOConverter());
    realm.close();
    return todoList;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:9,代码来源:TodoListRepositoryImpl.java

示例10: clearInstance

import io.realm.Realm; //导入方法依赖的package包/类
public static void clearInstance()  {
    Realm realm = Realm.getInstance(configuration);
    realm.beginTransaction();
    realm.delete(UserFactoryStore.class);
    realm.commitTransaction();
    realm.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:UserFactory.java

示例11: getItemById

import io.realm.Realm; //导入方法依赖的package包/类
@Override
public Optional<TodoListItem> getItemById(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    Optional<TodoListItemDAO> itemDAO = Optional.fromNullable(realm.where(TodoListItemDAO.class).equalTo("uuid", uuid).findFirst());
    Optional<TodoListItem> item = itemDAO.transform(new TodoListItemDAOConverter());
    realm.close();
    return item;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:9,代码来源:TodoListRepositoryImpl.java

示例12: sendReport

import io.realm.Realm; //导入方法依赖的package包/类
private void sendReport(@Nullable Station correctStation) {
    // build report
    Map<String, Object> map = new HashMap<>();
    if (incorrectStation == null) {
        map.put("incorrectStation", "none");
    } else {
        map.put("incorrectStation", incorrectStation.getId());
    }
    if (correctStation == null) {
        map.put("correctStation", "none");
    } else {
        map.put("correctStation", correctStation.getId());
    }
    map.put("wiFiScanResults", scanResults);

    ObjectMapper mapper = new ObjectMapper();
    try {
        String jsonResult = mapper.writerWithDefaultPrettyPrinter()
                .writeValueAsString(map);
        Realm realm = Realm.getDefaultInstance();
        realm.beginTransaction();
        Feedback feedback = realm.createObject(Feedback.class, UUID.randomUUID().toString());
        feedback.setSynced(false);
        feedback.setTimestamp(new Date());
        feedback.setType("s2ls-incorrect-detection");
        feedback.setContents(jsonResult);
        realm.copyToRealm(feedback);
        realm.commitTransaction();
        realm.close();

        Intent intent = new Intent(ACTION_FEEDBACK_PROVIDED);
        intent.putExtra(EXTRA_FEEDBACK_PROVIDED_DELAYED, !Connectivity.isConnected(context));
        LocalBroadcastManager bm = LocalBroadcastManager.getInstance(context);
        bm.sendBroadcast(intent);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:39,代码来源:FeedbackUtil.java

示例13: closeTestRealms

import io.realm.Realm; //导入方法依赖的package包/类
/**
 * Explicitly close all held realms.
 * <p>
 * 'testRealms' is accessed from both test and main threads.
 * 'testRealms' is valid after {@code before}.
 */
public void closeTestRealms() {
    List<Realm> realms = new ArrayList<>();
    synchronized (lock) {
        List<Realm> tmp = testRealms;
        testRealms = realms;
        realms = tmp;
    }

    for (Realm testRealm : realms) {
        testRealm.close();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RunInLooperThread.java

示例14: exportRepository

import io.realm.Realm; //导入方法依赖的package包/类
public static boolean exportRepository(File destination, String activeRealm) {
    if(!destination.exists()) {

        RealmConfiguration configuration = createConfiguration(activeRealm);
        Realm realm = Realm.getInstance(configuration);
        realm.writeEncryptedCopyTo(destination, letMeReadImLegit());
        realm.close();
        return true;
    }
    return false;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:12,代码来源:RepositoryManager.java

示例15: complexQuery

import io.realm.Realm; //导入方法依赖的package包/类
private String complexQuery() {
    String status = "\n\nPerforming complex Query operation...";

    Realm realm = Realm.getDefaultInstance();
    status += "\nNumber of persons: " + realm.where(Person.class).count();

    // Find all persons where age between 7 and 9 and name begins with "Person".
    RealmResults<Person> results = realm.where(Person.class)
            .between("age", 7, 9)       // Notice implicit "and" operation
            .beginsWith("name", "Person").findAll();
    status += "\nSize of result set: " + results.size();

    realm.close();
    return status;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:IntroExampleActivity.java


注:本文中的io.realm.Realm.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。