我创建了一个数据库助手类,我在其中编写了一个这样的选择查询:
//select statement
public String select(String question_id) {
SQLiteDatabase db = this.getWritableDatabase();
String sql = "SELECT answer FROM answers WHERE _id="+question_id;
Log.i("select: ",sql);
db.close();
return sql;
}
这就是我从活动中调用 select 方法的方式:
//select statement to retrive previous answer from database
DataBaseHelper db = new DataBaseHelper(ExamActivity.this);
ContentValues values = new ContentValues();
try {
db.createDataBase();
chk_content = db.select(question_sr_no.getText().toString());
} catch (IOException e1) {
e1.printStackTrace();
}
db.close();
但是logcat的输出是:
SELECT answer FROM answers WHERE _id=1.
为什么查询不返回结果,而是返回查询字符串?
提前致谢!