很多次我尝试使用 rawQuery() 来获取值,但游标总是返回 0 行,尽管有符合条件的有效行。这是我的代码:
public Cursor getChapIdForAudit(String auditid) {
// TODO Auto-generated method stub
//String sql="SELECT DISTINCT ChapterID FROM Results WHERE AuditID = "+auditid;
Cursor c= sp.rawQuery("SELECT ChapterID FROM Results WHERE AuditID ="+auditid,null);
c.moveToFirst();
return c;
}
来电代码:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent i= getIntent();
String auditid=i.getExtras().getString("audit_id");
ResultsTableManager results= new ResultsTableManager(ScoringRecordsActivity.this);
results.open();
Cursor chapIdCursor=null;
chapIdCursor= results.getChapIdForAudit(auditid);
System.out.println(chapIdCursor.getCount());
}