當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。