Get int array from database Cursor
If you were going to use the above you could still utilise Java's autoboxing feature, but there is a shorter form as hinted at by Darth Beleg.

Untested:

int[] ret = new int[c.getCount()];
if (c.moveToFirst())
    for (int i = 0; i &lt; c.getCount();) {
        ids[i++] = c.getInt(2);
        c.moveToNext();
    }
}


Although it is not pertinent to your case it is worth remembering that

ret[i] = iterator.next().intValue();


could throw a NPE.