title: SQLite DB accessed from multiple threads
body: <p>Consider following: I've got <code>Service</code>, which writes into DB in <code>AsyncTask</code>. And my Activity reads data from DB(consider UI thread for simplicity). I access DB using <code>SQLiteOpenHelper</code>. I create single instance in <a href="http://developer.android.com/reference/android/app/Application.html#onCreate%28%29" rel="noreferrer">Application onCreate()</a> and then obtain it in service and activity. Is there any possibility that I would get my DB 'dead locked'? Previously, I used ContentProvider for such operations. Though, it is based on using single <code>SQLiteOpenHelper</code> instance, I decided to simplify my project by excluding <code>ContentProvider</code>. </p>
  
  <p>Consider code:</p>
  
  <pre><code>public class App extends Application {
  
      private OpenHelper openHelper;
  
      @Override
      public void onCreate(){
          super.onCreate();
              openHelper=new OpenHelper();
      }
  
          public OpenHelper getHelper(){
              return openHelper;
          }
  }
  </code></pre>
  
  <p>In Activity:</p>
  
  <pre><code>OpenHelper helper=(App)getApplication().getHelper();
  SQLiteDatabase db=helper.getReadableDatabase();
  // Do reading
  </code></pre>
  
  <p>And inside Serice, in separate thread:</p>
  
  <pre><code>OpenHelper helper=(App)getApplication().getHelper();
  SQLiteDatabase db=helper.getWritableDatabase();
  //Do writing
  </code></pre>
  
  <p>Would it be safe?</p>
  
  <p><strong>UPD</strong> <a href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#setLockingEnabled%28boolean%29" rel="noreferrer">This</a> might be the solution, but not sure how to use it.</p>