title: SQLiteException: cannot start a transaction within a transaction (code 1)
body: <p>I'm having a problem finishing an SQLite transaction and I'm totally baffled on how to do it. It totally looks like <a href="https://bugs.launchpad.net/storm/+bug/136771" rel="noreferrer">this bug</a> from 2007.</p>
  <p>I'm creating my <code>employee</code> table (which references another table <code>entity</code>) as follows (edited for brevity):</p>
  <pre><code>CREATE TABLE employee (_id INTEGER NOT NULL, PRIMARY KEY ( _id ) , 
  FOREIGN KEY (_id) REFERENCES entity(_id)  ON DELETE cascade ON UPDATE cascade DEFERRABLE INITIALLY DEFERRED )
  </code></pre>
  <p>Then I run a transaction as follows (using a <code>SQLiteDatabase</code> object, I also report status for transaction in log):</p>
  <pre><code>&gt;&gt; In transaction: false
  beginTransaction();
  &gt;&gt; In transaction: true
  doSomeWrongINSERT();
  setTransactionSuccessful();
  endTransaction();
  &gt;&gt; In transaction: false
  SQLiteConstraintException: foreign key constraint failed (code 19)
  </code></pre>
  <p>Ok, all normal. Now if I try to start a new transaction or rollback, both fail:</p>
  <pre><code>&gt;&gt; In transaction: false
  beginTransaction();
  android.database.sqlite.SQLiteException: cannot start a transaction within a transaction (code 1)
  </code></pre>
  <hr />
  <pre><code>&gt;&gt; In transaction: false
  endTransaction();
  java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
  </code></pre>
  <p>Please note all this did not happen if FKs are immediate instead of deferred.</p>
  <hr />
  <p>Bug report: <a href="https://issuetracker.google.com/issues/37001653" rel="noreferrer">https://issuetracker.google.com/issues/37001653</a></p>