Android - Cursor not finding Column
<p>I'm trying to get the results from a Cursor and put them in into an Object that I created.  In Eclipse, it appears the cursor is returning a single row (which is what I want) but when I try to access it, I get an error.  Here's the code to fetch a single row:</p>

<pre><code>public Object fetchIssue(long IssueNumber, int type){

    //Get query cursor.
    Cursor cursor = mDB.query(true, ISSUES_TABLE, ISSUES_COLUMN_ARRAY, COL_ISSUE_ID + "=" + IssueNumber, null, null, null, null, null);

    int iCount = cursor.getCount();

    if(cursor == null)
        return null;

    Object objOut = null;

    if(type == QUERY_TYPE_STRING_ARRAY){
        //Create Array to hold Issue Information.
        String[] IssueInfo = new String[3];
        IssueInfo[0] = String.valueOf(IssueNumber);
        IssueInfo[1] = cursor.getString(cursor.getColumnIndexOrThrow(COL_DATE_RECEIVED));
        IssueInfo[2] = cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_SUMMARY));
        IssueInfo[3] = cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_STATUS));
        IssueInfo[4] = cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_SUB_STATUS));
        IssueInfo[5] = cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_DESCRIPTION));
        objOut = IssueInfo;
    }
    else{
        //Create IssueInfo object.
        IssueInfo IssueInfo = new IssueInfo(
                    IssueNumber, "12/12/2000",
                    //cursor.getString(cursor.getColumnIndexOrThrow(COL_DATE_RECEIVED)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_SUMMARY)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_STATUS)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_SUB_STATUS)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_DESCRIPTION)));
        objOut = IssueInfo;
    }

    //Close cursor.
    cursor.close();

    //Return IssueInfo.
    return objOut;
}
</code></pre>

<p>iCount returns 1 and if I put the cursor variable in the "variables" window, I can see all the columns:
<img src="http://i.stack.imgur.com/1wl4y.png" alt="Cursor variable"></p>

<p>and at the top of the class, the table column variables are set to the same name:</p>

<pre><code>public static final String ISSUES_TABLE = "Issues";
public static final String COL_ISSUE_ID = "_id";
public static final String COL_DATE_RECEIVED = "DateReceived";
public static final String COL_ISSUE_STATUS = "IssueStatus";
public static final String COL_ISSUE_SUB_STATUS = "IssueSubStatus";
public static final String COL_ISSUE_SUMMARY = "IssueSummary";
public static final String COL_ISSUE_DESCRIPTION = "IssueDescription";

private static final String[] ISSUES_COLUMN_ARRAY = new String[]{
    COL_ISSUE_ID, COL_DATE_RECEIVED, COL_ISSUE_SUMMARY, 
    COL_ISSUE_STATUS, COL_ISSUE_SUB_STATUS, COL_ISSUE_DESCRIPTION};
</code></pre>

<p>The error is occuring on this line:</p>

<pre><code>//Create IssueInfo object.
        IssueInfo IssueInfo = new IssueInfo(
                    IssueNumber, "12/12/2000",
                    //cursor.getString(cursor.getColumnIndexOrThrow(COL_DATE_RECEIVED)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_SUMMARY)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_STATUS)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_SUB_STATUS)),
                    cursor.getString(cursor.getColumnIndexOrThrow(COL_ISSUE_DESCRIPTION)));
</code></pre>

<p>or any of those lines (as you can see, I commented out the Date Received and put a normal string value in there, which it takes).</p>

<p>Here's the error:</p>

<pre><code>03-13 09:06:42.370: E/AndroidRuntime(2324): FATAL EXCEPTION: AsyncTask #2
    03-13 09:06:42.370: E/AndroidRuntime(2324): java.lang.RuntimeException: An error occured while executing doInBackground()
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at android.os.AsyncTask$3.done(AsyncTask.java:278)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.lang.Thread.run(Thread.java:856)
    03-13 09:06:42.370: E/AndroidRuntime(2324): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:400)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at com.adacel.dashboard.DBAdapter.fetchIssue(DBAdapter.java:215)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at com.adacel.dashboard.IssueInfoCreator.fetchIssue(IssueInfoCreator.java:42)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at com.adacel.dashboard.ViewIssue.LoadIssueDetails(ViewIssue.java:73)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at com.adacel.dashboard.ViewIssue.access$0(ViewIssue.java:70)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at com.adacel.dashboard.ViewIssue$GetIssueDetailsTask.doInBackground(ViewIssue.java:96)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at com.adacel.dashboard.ViewIssue$GetIssueDetailsTask.doInBackground(ViewIssue.java:1)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at android.os.AsyncTask$2.call(AsyncTask.java:264)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    03-13 09:06:42.370: E/AndroidRuntime(2324):     ... 4 more
</code></pre>

<p>Any help is greatly appreciated!</p>
