I am using android studio to handle database SQLite. I need to list all the items in a table as items in a listview..How can i do it. I know how to get the first item using cursor.moveToFirst() like this
public Rows getRows(){
String query = "SELECT * FROM "+TABLE_NAME;
SQLiteDatabase db = getWritableDatabase();
cursor = db.rawQuery(query,null);
Rows rows;
if(cursor.moveToFirst()){
rows.setcol1(cursor.getString(0));
rows.setcol2(cursor.getString(1));
rows.setcol3(cursor.getString(2));
cursor.close();
}
else{
rows=null;
}
return rows;
}
can i use cursor.moveToNext() if yes please give me the code....
Aucun commentaire:
Enregistrer un commentaire