本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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;
}