I have written some thing like this to fetch data from the database.
public String getData() {
// TODO Auto-generated method stub
String[] columns = new String[]{ KEY_ROWID, KEY_NAME, KEY_SCORE};
Cursor c = ourDatabase.query(
DATABASE_TABLE, columns, null, null, null, null, null);
String result = "";
int iRow = c.getColumnIndex(KEY_ROWID);
int iName = c.getColumnIndex(KEY_NAME);
int iHotness = c.getColumnIndex(KEY_SCORE);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
result = result + c.getString(iRow) + " " + c.getString(iName) + " " + c.getString(iHotness) + "\n";
}
return result;
}
and i am able to show data into textview. But i want to show data into listview can anyone suggest me or give me a sample code to show data into listview. I had taken a list.xml and put a listview in that. I want to fetch data from the database.
thanks in advance.
Then in the ListView onCreate you add the result string to you adapter.