public String getCourse_info (String courseID) {
String[] columns = new String[] {KEY_COURSE_ID, KEY_COURSE_TITLE, KEY_COURSE_CNUMBER, KEY_COURSE_SUBJECT, KEY_COURSE_DAYS,
KEY_COURSE_START_TIME, KEY_COURSE_END_TIME, KEY_COURSE_PROFESSOR, KEY_COURSE_BUILDING, KEY_COURSE_ROOM_NUMBER };
Cursor c = ourDataBase.query(DATABASE_TABLE_COURSES, columns, KEY_COURSE_ID + "=?", new String[]{courseID}, null, null, null);
String result = "";
int iCid = c.getColumnIndex(KEY_COURSE_ID);
int iCtitle = c.getColumnIndex(KEY_COURSE_TITLE);
int iCcnumber = c.getColumnIndex(KEY_COURSE_CNUMBER);
int iCsubject = c.getColumnIndex(KEY_COURSE_SUBJECT);
int iCdays = c.getColumnIndex(KEY_COURSE_DAYS);
int iCstart_time = c.getColumnIndex(KEY_COURSE_START_TIME);
int iCend_time = c.getColumnIndex(KEY_COURSE_END_TIME);
int iCprofessor = c.getColumnIndex(KEY_COURSE_PROFESSOR);
int iCbuilding = c.getColumnIndex(KEY_COURSE_BUILDING);
int iCroom_number= c.getColumnIndex(KEY_COURSE_ROOM_NUMBER);
for(c.moveToFirst(); !c.isAfterLast();c.moveToNext()){
result = result + c.getString(iCid)+ " " +c.getString(iCtitle)+ " "+c.getString(iCcnumber)+" "+ c.getString(iCsubject) + " "+
c.getString(iCdays)+ " "+ c.getString(iCstart_time)+ " "+ c.getString(iCend_time) +" " +
c.getString(iCprofessor) + " "+ c.getString(iCbuilding) + " " + c.getString(iCroom_number)+ "\n" ;
}
Log.d("hello", result+"test2");
return result;
}
好的,我正在尝试在数据库中的一张表上运行此代码。问题是如果我通过数据库中的第一个 course_id,它就可以完美运行。但是当我尝试在之后放置 2nd 或任何 course_id 时,字符串不会显示任何内容。