I have the following problem using an ArrayList
of ArrayList
. I do the next:
Hashtable<SensorType, ArrayList<Float>> hash = new Hashtable<SensorType, ArrayList<Float>>();
int numKeys = sensors.size();
ArrayList<ArrayList<Float>> arrays = new ArrayList<ArrayList<Float>>(numKeys);
for(int i = 0; i < arrays.size(); i++){
ArrayList<Float> aux = new ArrayList<Float>();
arrays.add(aux);
}
String columns = getColumnsName(sensors);
String sql = "select " + columns + " from " + nameTable + " where " + ID + " BETWEEN " +
start + " AND " + end + ";";
Cursor c = db.rawQuery(sql, null);
c.moveToFirst();
while(!c.isAfterLast()){
for(int i = 0; i < numKeys; i++)
arrays.get(i).add(c.getFloat(i));
c.moveToNext();
}
This always gives me an ArrayOutOfBoundsException
. It tells that the size of every array (inner) is 0. What am I doing wrong?