I've got an XML file storing an array of shorts in my resources. I need to assign this array, but Android API only provides a way to get array of ints (getResources.getIntArray()
). I've ended up getting an array of ints and converting it to array of shorts later, but that's hardly ideal.
Is there a way to get an array of shorts from Android resources? If not, is there a more efficient/cleaner way of converting int array into short array? My code currently looks like this:
int indicesInt[] = context.getResources().getIntArray(R.array.indices);
short indices[] = new short[indicesInt.length];
for (int i = 0; i < indicesInt.length; i++) {
indices[i] = (short)indicesInt[i];
}