Advertisement
Guest User

Untitled

a guest
May 27th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public void addAsync(final String title, final String content, final int color) {
  2. mRealm.executeTransactionAsync(new Realm.Transaction() {
  3. @Override
  4. public void execute(Realm realm) {
  5.  
  6. long id = notePrimaryKey.getAndIncrement();
  7.  
  8. Note note = new Note();
  9. note.setTitle(title);
  10. note.setContent(content);
  11. note.setColor(color);
  12. note.setId(id);
  13.  
  14. realm.copyToRealmOrUpdate(note);
  15. }
  16. }, new Realm.Transaction.OnSuccess() {
  17. @Override
  18. public void onSuccess() {
  19. Log.d(LOG_TAG, "Note Added");
  20. }
  21. }, new Realm.Transaction.OnError() {
  22. @Override
  23. public void onError(Throwable error) {
  24. Log.d(LOG_TAG, error.getMessage());
  25. }
  26. });
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement