title: Sqlite how to improve performance?
body: <p>I have to make more than 300 selects from my database.
  Each of those queries has to be called inside of a for each loop, here's an example:</p>
  
  <pre><code>for(int id : myids){
      Cursor cursor = MyDatabaseHelper.runMyQuery(id);
      while(cursor.moveToNext()){
          //my stuff...
      }
  }
  </code></pre>
  
  <p>MyDatabaseHelper is an instance of a database helper class, the function is like this</p>
  
  <pre><code>public Cursor runMyQuery(int id){
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor ret = db.rawQuery("select Name, Surname, Age from PTable where Id = " + id, null);
      return ret;
  }
  </code></pre>
  
  <p>I've been told that the constant "open and close" of the db because of multiple queries it the cause of my performance issues and I should, instead, make a single query (using union etc).
  Changing my code to a single query would mean changing the entire database, and I was hoping not to do that.</p>
  
  <p>Is there anything I can do to improve the performance and keep the multiple selects at the same time?
  Thanks</p>