use of me.yluo.ruisiapp.model.ReadHistoryData in project Ruisi by freedom10086.
the class MyDB method getHistory.
public List<ReadHistoryData> getHistory(int num) {
getDb();
List<ReadHistoryData> datas = new ArrayList<>();
String sql = "SELECT * FROM " + TABLE_READ_HISTORY + " order by read_time desc limit " + num;
// 执行查询语句
Cursor result = this.db.rawQuery(sql, null);
// 采用循环的方式查询数据
for (result.moveToFirst(); !result.isAfterLast(); result.moveToNext()) {
datas.add(new ReadHistoryData(result.getString(0), result.getString(1), result.getString(3), result.getString(2)));
}
result.close();
this.db.close();
return datas;
}
Aggregations