I am having a problem displaying data from my DB in a list view. the below is the code from for my display method.
Display
public ArrayList<Object> display(String rows) {
ArrayList<Object> rowArray = new ArrayList<Object>();
String[] columns = new String[] { KEY_ROWID, KEY_PACKNAME,
KEY_PACKRENT, KEY_SIMRATE, KEY_NATMINSBUN, KEY_INTMINSBUN,
KEY_INTMINSRATE, KEY_NATSMSBUN,
KEY_NATSMSRATE, KEY_INTSMSBUN, KEY_INTSMSRATE,
KEY_MMSBUN, KEY_MMSRATE, KEY_DATALBUN,
KEY_DATALRATE };
Cursor cursor = ourDatabase.query(DATABASE_TABLE, columns, null, null,
null, null, null);
cursor.moveToFirst();
if (!cursor.isAfterLast())
{
do
{
rowArray.add(cursor.getLong(0));
rowArray.add(cursor.getString(1));
rowArray.add(cursor.getString(2));
rowArray.add(cursor.getString(3));
rowArray.add(cursor.getString(4));
rowArray.add(cursor.getString(5));
rowArray.add(cursor.getString(6));
rowArray.add(cursor.getString(7));
rowArray.add(cursor.getString(8));
rowArray.add(cursor.getString(9));
rowArray.add(cursor.getString(10));
rowArray.add(cursor.getString(11));
rowArray.add(cursor.getString(12));
rowArray.add(cursor.getString(13));
rowArray.add(cursor.getString(14));
} while (cursor.moveToNext());
cursor.close();
}
return rowArray;
}
This is the Arraylist
EtiTariffDatabase test = new EtiTariffDatabase(this);
TextView TV = (TextView) findViewById(R.id.s_etipackname);
TextView TV1 = (TextView) findViewById(R.id.s_etipackrent);
TextView TV2 = (TextView) findViewById(R.id.srentalrate);
TextView TV3 = (TextView) findViewById(R.id.snationalbun);
TextView TV4 = (TextView) findViewById(R.id.seintbun);
TextView TV5 = (TextView) findViewById(R.id.senatsmsbun);
TextView TV6 = (TextView) findViewById(R.id.seintsmsbun);
TextView TV7 = (TextView) findViewById(R.id.sedatalocalbun);
test.open();
try
{
ArrayList<Object> row = test.display(null);
TV.setText((String)row.get(1));
TV1.setText((String)row.get(2));
TV2.setText((String)row.get(3));
TV3.setText((String)row.get(4));
TV4.setText((String)row.get(6));
TV5.setText((String)row.get(8));
TV6.setText((String)row.get(10));
TV7.setText((String)row.get(12));
}
catch (Exception e)
{
Log.e("Retrieve Error", e.toString());
e.printStackTrace();
}
test.close();
}
the exception I catch is:
04-07 16:48:23.759: E/Retrieve Error(4134): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
04-07 16:48:23.829: W/System.err(4134): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
04-07 16:48:23.829: W/System.err(4134): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
I have been trying to play around for a long time. It worked initially but I deleted the DB and recreated it. From then no data gets displayed with me having the above error. Any assistance would be greatly appreciated.