我多次尝试使用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());
}