title: Android SQLite how to get particular column:row value
body: <p>I have a database and I am doing a query to it using</p>
  
  <p><code>Cursor mCursor = mapDb.query(MY_TABLE, new String[] {KEY_ONEID, KEY_TWOID}, "trim("+KEY_TWOID + ") != '' ", null, null, null, null);</code></p>
  
  <p>which in SQL terms literally means:
  <code>SELECT OneId, TwoId FROM auth WHERE trim(TwoId) != ''</code></p>
  
  <p>Using the raw SQL query this works in my SQLite browser to show me the rows in question, so the Cursor object should contain the same results.</p>
  
  <p>Secondly in my java method I am using a condition to check if this result has anything</p>
  
  <pre><code>    if(mCursor.getColumnIndex(KEY_ONEID) &gt; -1)  //if &gt; -1 then the mCursor returned a row
      {
  
         if(mCursor.getString(mCursor.getColumnIndex(KEY_ONEID)).contains(id)) //breaks here
                  return mCursor.getString(mCursor.getColumnIndex(KEY_TWOID));
              else
                  return "";
      }
  </code></pre>
  
  <p>But for some reason, even though the mCursor hashmap should have all the values returned, this next conditional statement</p>
  
  <p><code>mCursor.getString(mCursor.getColumnIndex(KEY_ONEID)).contains(id)</code></p>
  
  <p>still returns: <code>An exception occurred: android.database.CursorIndexOutOfBoundsException</code></p>
  
  <p>this is the line that throws the exception: <code>mCursor.getString(mCursor.getColumnIndex(KEY_ONEID))</code> and so does my next item in the return statement</p>
  
  <p>I'm baffled at how to retrieve a particular row value then! because I have pulled the database and run the same query and can clearly see that both of the values I want, do in fact exist!</p>
  
  <p>the Cursor function doesn't provide many other ways to retrieve values, so insight appreciated!</p>