ArrayIndexOutOfBoundsException error... why?
<p>I'm a bit lost on this one. How can I get an OutOfBounds? Is there a size limit (besides sizeof (int))?</p>

<p>Maybe because <strong>multiple threads</strong> can come here? The UI thread and a Service thread?</p>

<blockquote>
  <p>java.lang.ArrayIndexOutOfBoundsException at
  kenyu73.realsignal.DatabaseWrapper.getSignalValues(DatabaseWrapper.java:137) at
  kenyu73.realsignal.DatabaseWrapper.getSignalValues(DatabaseWrapper.java:116) at
  kenyu73.realsignal.BarScaleGraph$buildGraphThread.drawGraph(BarScaleGraph.java:128)
  at
  kenyu73.realsignal.BarScaleGraph$buildGraphThread.execute(BarScaleGraph.java:94)
  at
  kenyu73.realsignal.BarScaleGraph$buildGraphThread.run(BarScaleGraph.java:74)</p>
</blockquote>

<p>Also, I'm calling this classes methods with a <strong>static instance</strong>. I'm thinking threads are competing for the same variables??? Thoughts?</p>

<p><strong>BarScaleGraph class</strong></p>

<pre><code>ContentValues[] values = DatabaseWrapper.getInstance().getSignalValues(getContentResolver(), signal_type, false);
</code></pre>

<p><strong>DatabaseWrapper class</strong></p>

<pre><code>private static final DatabaseWrapper    instance    = new DatabaseWrapper();

// grab static instance so we only have one db wrapper
public static DatabaseWrapper getInstance() {
    return instance;
}

. . . .

public ContentValues[] getSignalValues(ContentResolver cr, int signal_type_id, boolean bGroupByLatLon) {

    String sWhere = "signal_type_id=" + signal_type_id;

    Cursor cursor;

    if (bGroupByLatLon) {
        cursor = cr.query(CONSTS.CONTENT_URI_GRP_LATLNG, null, sWhere, null, null);
    } else {
        cursor = cr.query(CONSTS.CONTENT_URI_LOGGER, null, sWhere, null, null);
    }

    ContentValues[] values = new ContentValues[cursor.getCount()];

    int count = 0;
    if (cursor.getCount() &gt; 0) {
        cursor.moveToFirst();
        do {
            values[count] = new ContentValues(); // &lt;--- LINE 137
            values[count].put("signal_value", cursor.getInt(cursor.getColumnIndex("signal_value")));
            values[count].put("latitude", cursor.getInt(cursor.getColumnIndex("latitude")));
            values[count].put("longitude", cursor.getInt(cursor.getColumnIndex("longitude")));
            values[count].put("timestamp", cursor.getLong(cursor.getColumnIndex("timestamp")));
            values[count].put("network", cursor.getString(cursor.getColumnIndex("network")));

            count++;

        } while (cursor.moveToNext());
    }
    cursor.close();

    return values;
}
</code></pre>

<p><strong>EDIT</strong>: Going to try this - add <strong>synchronized</strong> to the instance</p>

<pre><code>// grab static instance so we only have one db wrapper
public static synchronized DatabaseWrapper getInstance() {
    return instance;
}
</code></pre>
