title: Why/When to use realm.beginTransaction? Since there are executeTransaction and executeTransactionAsync
body: <p>For instance, if I have this pieces of code:</p>
  <pre><code>Realm realm = Realm.getDefaultInstance();
  
  realm.beginTransaction();
  mUser.setName(&quot;Roy&quot;);
  realm.commitTransaction();
  
  textView1.setText(mUser.getName());
  </code></pre>
  <p>Based on the document, it says that the <code>Exception</code> will be caught and data won't be persisted if there is an error inside a transaction. So in above code, say if something wrong in <code>mUser.setName(&quot;Roy&quot;);</code> or <code>realm.commitTransaction();</code>, there won't be a crash and the code will still continue? However,<code>cancelTransaction</code> isn't called in this case. What will happen? <strong>Update</strong>: Looks like the app won't crash, but next time if you continue to read something from Realm it will crash and tell you that the Realm is locked, because commitTransaction is not called.</p>
  <p>I just cant't figure out in what chances you will use <code>beginTransaction</code> and <code>commitTransaction</code> if there is a risk that errors might happen. There are alreay <code>executeTransaction</code> and <code>executeTransactionAsync</code> can handle it well. Especially with <code>executeTransactionAsync</code>, I guess most of you will use <code>executeTransactionAsync</code> as it has <code>onSuccess</code> and <code>onError</code>.</p>
  <p>To me, I can only think of one reason: I want to just do a simple data update and still use the same thread, but in that case I will use below code instead, which is less error-prone.</p>
  <pre><code>try {
      realm.executeTransaction(new Realm.Transaction() {
          @Override
          public void execute(Realm realm) {
              mUser.setName(&quot;Roy&quot;);
          }
      });
  } catch (Exception e) {
      Logger.e(TAG, &quot;error&quot;, e);
      Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_SHORT).show();
      return;
  }
  </code></pre>