title: Error: Make sure the Cursor is initialized correctly before accessing data from it?
body: <p>I have cursor initialized as follows: </p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //...Code, code, code...
  
          c = db.query("US_States", null, null, null, null, null, null, null);
  
  
      }
  </code></pre>
  
  <p>The cursor itself is used in a separate method within the same activity: </p>
  
  <pre><code>public void GameStart()
      {
          int gameCount = 0;
          while(gameCount &lt; 5)
          {
              cursorEntry = new Random().nextInt(c.getCount());
              c.moveToPosition(cursorEntry);
              cursorState = c.getString(1);
              cursorCapital = c.getString(2);
              displayText.setText(cursorState);
  </code></pre>
  
  <p>It gives me the following error: </p>
  
  <pre><code>E/CursorWindow﹕ Failed to read row 20, column 2 from a CursorWindow which has 50 rows, 2 columns.
  </code></pre>
  
  <p>With a stack trace pointing at this line <code>cursorCapital = c.getString(2);</code> every time I rerun the application. It always gives an error there. </p>
  
  <p>The database something like this: </p>
  
  <pre><code>State|Capital
  Alabama|Montgomery
  Alaska|Juneau
  Arizona|Phoenix
  ...The rest of the states
  </code></pre>
  
  <p>I read a couple of similar posts on SO, but they didn't give me an idea of what is going wrong. Any input is appreciated. </p>