Uzyskaj dane z bazy danych SQLite Android
//Put this in your DAO or actyvity
public ArrayList<yourclass> getfromdatabase() {
String strSql = "select * from yourtable";
getdatabase = new ArrayList<yourclass>();
SQLiteDatabase db = dbHelper.getReadableDatabase();
Cursor c = db.rawQuery(strSql, null);
if (c.moveToFirst()) {
do {
yourclass = new yourclass();
yourclass.setId(c.getInt(c.getColumnIndex("yourcolumnname")));
yourclass.setTitulo(c.getString(c.getColumnIndex("yourcolumnname")));
yourclass.setTexto(c.getString(c.getColumnIndex("yourcolumnname")));
yourclass.setTipo(c.getString(c.getColumnIndex("yourcolumnname")));
getdatabase.add(yourclass);
} while (c.moveToNext());
}
return getdatabase;
}
MGT EDITS