1
我的要求是當我傳遞一些需要發送對象的參數查詢時。不是列表。Android Sqlite查詢
我寫的代碼:
public RDExecutive getExecutiveObject(String executivename){
DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
dbAdapter.openDataBase();
System.out.println(" ---- executivename --- " + executivename);
String query="SELECT * FROM RDExecutive WHERE ExecutiveName = ?';";
String[]d = new String[]{executivename};
ArrayList stringList = dbAdapter.selectRecordsFromDBList(query, d);
dbAdapter.close();
ArrayList<Object> rdExecutiveObject = new ArrayList<Object>();
RDExecutive rdExecutive = new RDExecutive();
System.out.println(" -- stringList.size() -- " + stringList.size());
for (int i = 0; i < stringList.size(); i++) {
ArrayList<Object> arrayList2 = (ArrayList<Object>) stringList.get(i);
ArrayList<Object> arrayList = arrayList2;
ArrayList<Object> list = arrayList;
try {
rdExecutive.setBusinessUnit((String) list.get(0));
rdExecutive.setExecutiveCode((String) list.get(1));
rdExecutive.setExecutiveName((String) list.get(2));
rdExecutive.setTerritoryCode((String) list.get(10));
} catch (Exception e) {
Log.i("***" + SalesRouteActivity.class.toString(), e.getMessage());
}
rdExecutiveObject.add(rdExecutive);
}
return rdExecutive;
}
此方法返回RDExecutive對象。
當我運行這一部分中,我得到了錯誤
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xont.controller/com.xont.controller.DownlaodTableActivity}:
android.database.sqlite.SQLiteException: unrecognized token: "';": , while compiling:
SELECT * FROM RDExecutive WHERE ExecutiveName = ?';
我們想傳遞參數查詢怎麼辦。
非常感謝。 – Piraba