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