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


Java Realm.copyToRealm方法代碼示例

本文整理匯總了Java中io.realm.Realm.copyToRealm方法的典型用法代碼示例。如果您正苦於以下問題:Java Realm.copyToRealm方法的具體用法?Java Realm.copyToRealm怎麽用?Java Realm.copyToRealm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.realm.Realm的用法示例。


在下文中一共展示了Realm.copyToRealm方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: insert

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public boolean insert(Note note) {
    Realm realm = Realm.getInstance(configuration);
    final NoteDAO dao = RealmConverter.convert(note);

    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,代碼來源:NoteRepositoryImpl.java

示例3: onNotesEdit

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void onNotesEdit(String notes, int position) {
    if (notesFragment_LOG)
    Log.d(TAG, "onNotesEdit: " + notes);
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    notesList.get(position).setNote(notes);
    realm.copyToRealm(notesList.get(position));
    notesAdapter.notifyItemChanged(position);
    realm.commitTransaction();
}
 
開發者ID:Rishabhk07,項目名稱:multi-copy,代碼行數:12,代碼來源:NotesFragment.java

示例4: 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

示例5: send

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public void send(Message message, Callbacks.IRequestCallback callback) {
    Realm realm = Realm.getDefaultInstance();
    try {
        realm.beginTransaction();
        realm.copyToRealm( message);
        realm.commitTransaction();
    }catch (Exception ex){
        ex.printStackTrace();
    }
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:12,代碼來源:MessageLocalDataSource.java

示例6: copyToRealm

import io.realm.Realm; //導入方法依賴的package包/類
public static <T extends RealmModel> T copyToRealm(final Realm realm, final T model) {
    realm.beginTransaction();
    T unManagedModel = realm.copyToRealm(model);
    realm.commitTransaction();
    return unManagedModel;
}
 
開發者ID:Jusenr,項目名稱:androidgithub,代碼行數:7,代碼來源:DBManager.java


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