title: Android SQLite transactions and multi threads
body: <p>In my application, I call some webservices to update a database.
  Each webservice call is made in a specific thread, resulting in multiple threads updating the database object "at a time".</p>
  
  <p>In each thread, I use transactions like that :</p>
  
  <pre><code>Thread 1 (webservice 1)
  beginTransaction()
  insert a row in the table 1
  update a row in the table 1
  endTransaction()
  
  Thread 2 (webservice 2)
  beginTransaction()
  update a row in the table 2
  update a row in the table 2
  endTransaction()
  </code></pre>
  
  <p>But I struggle with one question I can't answer myself after googling it;
  As transactions are handled in different threads, are they distinct from each other? In other words, does the DB use a distinct "statement stack" or a common one?</p>
  
  <p>From my readings, I understand transactions are in the same stack, i.e commiting the transaction in thread 1 may commit updates on table 2.
  For example, DB statement stack as I think it may happen:</p>
  
  <pre><code>beginTransaction() //Thread 1 begins a transaction
  insert a row in the table 1
  update a row in the table 1
  beginTransaction() //Thread 2 begins a transaction
  update a row in the table 2
  update a row in the table 2
  endTransaction() //Thread 2 ends a transaction
  endTransaction() //Thread 1 ends a transaction
  </code></pre>
  
  <p>If it's true, how can I make my transactions really exclusives? Do I have to <code>BEGIN EXCLUSIVE TRANSACTION</code> and handle the <code>SQLITE_BUSY</code> error everywhere or is there something easier?</p>