我需要显示多个数据库表来分隔文字浏览。如何从SQLite对android进行排序?
,所以我需要从表中把所有“约会”和排序他们在MainActivity如txtMonday,txtTuesday,txtWednesday
数据库设计白天存储与其他一起在单独textviews显示细节:
private static final String DATABASE_CREATE =
"create table " + TABLE_AP + "(" + COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_DAY + " text not null, "
+ COLUMN_TIME + " text not null, "
+ COLUMN_DURATION + " text not null, "
+ COLUMN_DESCRIPTION + " text not null);";
这是我试图通过MainActivity调用它: (我也将用的onCreate调用它)
public void onResume(){
APData = new AppointmentDataSource(this);
APData.open();
List<Appointment> appointments = APData.retrieveAllAppointments();
APData.close();
AppointmentDataSource:
public List<Appointment> retrieveAllAppointments() {
List<Appointment> appointments = new ArrayList<Appointment>();
Cursor cursor = database.query(MySQLiteHelper.TABLE_AP, , null, null, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Appointment ap = cursorToBk(cursor);
appointments.add(ap);
cursor.moveToNext();
}
cursor.close();
return appointments;
}
也为天,我用单选按钮之间进行选择周一/周二/周三/周四/周五 ,所以我白天存储与:
createButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
findRadioGroup = (RadioGroup) findViewById(R.id.radioDay);
int selectedId = findRadioGroup.getCheckedRadioButtonId();
radioButton = (RadioButton) findViewById(selectedId);
String day=radioButton.getText().toString();
String time=txtTime.getText().toString();
String duration=txtDuration.getText().toString();
String description=txtDescription.getText().toString();
APData.insert(day, time, duration, description);
APData.close();
finish();
}
});
和XML他们/字符串:
<string name="RadioMon">Mon</string>
<string name="RadioTue">Tue</string>
<string name="RadioWed">Wed</string>
<string name="RadioThu">Thur</string>
<string name="RadioFri">Fri</string>
我不明白你想要排序?请更好地解释 – 2013-04-11 12:27:39
SQLiteDatabase的查询方法的最后一个参数包含SQL函数的“orderBy”参数。更多的信息在这里:http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html – AlexVogel 2013-04-11 12:43:16
对不起Tenhouse,我想整理一天,并把时间/时长/描述放在正确的文本视图下天 – user2253722 2013-04-11 13:20:25