我正在尝试从我的 android 应用程序中的 Sqlite 数据库返回数据(存储的锻炼信息:名称、周期、用户在特定日期播放的燃烧卡路里),但出现异常:
android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: SELECT Name, Period, Burned_Calories FROM Exercise WHERE Date = Tuesday, 8/May/2012
为什么会发生此异常,我该如何解决?请帮我 ..
这是我的代码:
DBAdapter db = new DBAdapter(this);
db.open();
String selected_date= date_btn.getText().toString();
Cursor c = db.getExerciseInfo(selected_date );
if (c.moveToFirst())
{
do
{
Toast.makeText(this ,"Name: "+ c.getString(0) + "\n" + "Period:" +c.getFloat(1)+ "\n" + " burned cals:" +c.getFloat(2)+ "\n" ,Toast.LENGTH_LONG).show();
}
while (c.moveToNext());
}
db.close();
这是我在 DBAdapter 类中的方法
public Cursor getExerciseInfo(String date) throws SQLException
{
Cursor C_excer = db.query(EXERCISE_TABLE_NAME, new String[] {KEY_NAME,KEY_PERIOD,KEY_BURNEDCALS},KEY_DATE +" = " + date, null, null, null, null);
if (C_excer != null) {
C_excer.moveToFirst();
}
return C_excer;
}