i have two mehods, one to collect SQL data and one to put it into a listview.. it seems i can't get the array to form correctly in the SQL part so that it can be passed tot the listview.
SQL act:
public String[] getDataInArray() { // get data for list and return in array form
// TODO Auto-generated method stub
String[] columms = new String[]{ KEY_ROWID, KEY_NAME};
String[] return_colums = null;
Cursor c = currentdatabase.query(DATABASE_TABLE, columms, null, null, null, null, null);
int iRow = c.getColumnIndex(KEY_ROWID);
int iName = c.getColumnIndex(KEY_NAME);
int rowcount = 0;
for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
{
return_colums[rowcount] = c.getString(iName) + "," + c.getString(iRow);
rowcount = rowcount + 1;
}
return return_colums;
}
And the listview act:
public ListView whiskeylist;
public String[] DataArryWhiskey;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Start db view of whiskey
DBConfig whiskeyrows = new DBConfig(this);
whiskeyrows.open();
DataArryWhiskey = whiskeyrows.getDataInArray();
whiskeyrows.close();
Toast.makeText(MainScreen.this, result, Toast.LENGTH_LONG).show();
whiskeylist = (ListView)findViewById(R.id.listofWhiskey);
whiskeylist.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , DataArryWhiskey));
// End db view of whiskey
}// end onCreate
I keeps on crashing, can anybody help met a bit? Thx in advance