title: Android SQLite column and index best practice
body: <p>I am starting to use SQLite in my Android app.  I'm not new to databases, I have many years do database work with Delphi which does take some of the work out of using databases.</p>
  
  <p>In an app, one may have a table with several columns. When reading data out of the table one executes some SQL, then uses a cursor to access the data.</p>
  
  <p>There are a couple of methods on the cursor to access the data, one uses the column index in the table - many of the examples I've seen on the net use this.  For example:</p>
  
  <pre><code>cursor.getString(3);
  </code></pre>
  
  <p>Having the "3" embedded in code is not the greatest idea, so you can use:</p>
  
  <pre><code>int idx = cursor.getColumnIndex( "THECOLUMNNAME" );
  cursor.getString(idx);
  </code></pre>
  
  <p>Using getColumnIndex() more than once for a table and column is wasteful.  Keeping constants of the indexes of what could be several 10s or 100s of columns is prone to error.</p>
  
  <p>My question is - what is the best practice for doing this sort of thing?</p>
  
  <p>Should I extend Cursor to better represent a specific table?  </p>
  
  <p>Thanks,</p>
  
  <p>Mike</p>