[Solved] Android App Crashing – List View – CSV file


Ok your program fails at this point:

while ((line = reader.readLine()) != null) {

        String[] RowData = line.split(",");
        DataStates cur = new DataStates();
        cur.setTitle(RowData[2]);
        cur.setPrice(RowData[3]);
        // now there is a ArrayIndexOutOfBoundsException
        cur.setDescription(RowData[4]);

        this.add(cur);
    }

Index begins at 0 so I think the right code would be

while ((line = reader.readLine()) != null) {

        String[] RowData = line.split(",");
        if(RowData.length <4)
             continue;
        DataStates cur = new DataStates();
        cur.setTitle(RowData[1]);
        cur.setPrice(RowData[2]);
        cur.setDescription(RowData[3]);

        this.add(cur);
    }

5

solved Android App Crashing – List View – CSV file