i've got a database what i wanted to display in a listview. i have something to work. heres the code:
Cursor cursor = myDataBase
.rawQuery(
"SELECT * FROM Accelerometer where cur_timestamp<'2012-09-04 11:36:25'",
null);
while (cursor.moveToNext()) {
// Which column you want to exprort
String arrStr[] = { cursor.getString(0)+" | " + cursor.getString(1)+" | " + cursor.getString(2)+" | "+ cursor.getString(3)+" | " + cursor.getString(4)+"\n" };
if (arrStr.length != 0) {
Log.d("TravellerLog :: ", Arrays.toString(arrStr));
//data.setText(Arrays.toString(arrStr));
ListView listView = (ListView) findViewById(R.id.listView1);
// a listát berakni aegy arraylist-be
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1,
arrStr);
listView.setAdapter(adapter);
} else {
Log.e("TravellerLog :: ", "Üres a tömb!");
}
}
cursor.close();
what should i change in the code to get it work?To list all the rows i want Thank you very much for the answers!