title: Do I need to call getWritableDatabase() everytime I manipulate data
body: <p>I have a newbie question about sqlite databases in android:</p>
  
  <p>Do I really need to retrieve a writeable database everytime I manipulate data?</p>
  
  <p>So can I write a DAO like this:</p>
  
  <pre><code>class Dao {
  
          private final SQLiteDatabase database;
  
          public Dao(SQLiteOpenHelper databaseHelper){
  
               database = databaseHelper.getWritableDatabase();
      }
  
      public void insert(...){
  
         ContentValues cv = new ContentValues(4);
         database.insertOrThrow(TABLE, null, cv);
         ...
      }
  
  
      public void update(...){
          ContentValues cv = new ContentValues(4);
          database.update(....);
      }
  }
  </code></pre>
  
  <p>or do I must write my dao like this:</p>
  
  <pre><code>class Dao {
  
          private final SQLiteOpenHelper databaseHelper;
  
          public Dao(SQLiteOpenHelper databaseHelper){
  
               this.databaseHelper = databaseHelper
      }
  
      public void insert(...){
  
         SQLiteDatabase database = databaseHelper.getWritableDatabase();
         ContentValues cv = new ContentValues(4);
         database.insertOrThrow(TABLE, null, cv);
         ...
      }
  
  
      public void update(...){
          SQLiteDatabase database = databaseHelper.getWritableDatabase();
          ContentValues cv = new ContentValues(4);
          database.update(....);
      }
  }
  </code></pre>
  
  <p>If the second approach is the correct one:
  do I also need to close the database after every operation:</p>
  
  <pre><code>public void update(...){
      SQLiteDatabase database = databaseHelper.getWritableDatabase();
      ContentValues cv = new ContentValues(4);
      database.update(....);
      database.close();
  }
  </code></pre>
  
  <p>I guess its the same for <code>databaseHelper.getReadableDatabase()</code> right?</p>