SQLクエリでエラーが発生し、コーディングを改善するために変更する必要があるものは何ですか
私のコードは
私のDBHelperコード
public Cursor fetchDaysAppointment(String from, String to){
Cursor c = ourDatabase.rawQuery("SELECT * FROM "+CUSTOMER_TABLE_NAME+
"WHERE (aDate >= ? AND aDate <= ?)",
new String[]{from, to});
if(c != null){
c.moveToFirst();
}
return c;
}
私のJavaコード
public void getDaysAppointment(int day, int month, int year){
String from = year+"-"+month+"-"+day+" 00:00:00";
String to = year+"-"+month+"-"+day+" 23:59:59";
in.open();
cursor = in.fetchDaysAppointment(from, to);
cursor.moveToFirst();
for(int i=0; i<cursor.getCount(); i++){
if(cursor.getInt(cursor.getColumnIndex("aTime")) == 8){
System.out.println("Hi the value is found to be Matched");
}
cursor.moveToNext();
}
}
ログ猫エラー
02-14 17:23:06.740: E/AndroidRuntime(4535): FATAL EXCEPTION: main
02-14 17:23:06.740: E/AndroidRuntime(4535): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ashadegreen/com.example.ashadegreen.Home}: android.database.sqlite.SQLiteException: near "(": syntax error: , while compiling: SELECT * FROM customerWHERE (aDate >= ? AND aDate <= ?)