Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addAsync(final String title, final String content, final int color) {
- mRealm.executeTransactionAsync(new Realm.Transaction() {
- @Override
- public void execute(Realm realm) {
- long id = notePrimaryKey.getAndIncrement();
- Note note = new Note();
- note.setTitle(title);
- note.setContent(content);
- note.setColor(color);
- note.setId(id);
- realm.copyToRealmOrUpdate(note);
- }
- }, new Realm.Transaction.OnSuccess() {
- @Override
- public void onSuccess() {
- Log.d(LOG_TAG, "Note Added");
- }
- }, new Realm.Transaction.OnError() {
- @Override
- public void onError(Throwable error) {
- Log.d(LOG_TAG, error.getMessage());
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement