我有一个 SimpleCursorAdapter,它从 SQLite 数据库中填充数据。它工作正常,但是“持续时间”列以毫秒为单位,我想在显示之前对其进行划分(持续时间 / 1000)。如果不在数据库中存储另一个持续时间(以分钟为单位)列,这可能吗?
适配器:
adapter = new SimpleCursorAdapter(getActivity(),
R.layout.rec_list_items,
db.selectAllRecords(),
new String[] { "day", "hour", "minute", "duration", "link" },
new int[] { R.id.textView_day, R.id.textView_hour, R.id.textView_minute, R.id.textView_duration, R.id.textView_link },
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
选择所有记录:
public Cursor selectAllRecords() {
String[] cols = new String[] {ID, DAY, HOUR, MINUTE, DURATION, LINK};
Cursor mCursor = database.query(true, TABLE,cols,null
, null, null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}