本文整理匯總了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;
}