0
應用程序不會運行。這種反覆出現:方法查詢db返回結果
04-05 21:29:09.570: E/AndroidRuntime(1069): Caused by: java.lang.IllegalArgumentException:
Cannot bind argument at index 1 because the index is out of range.
The statement has 0 parameters.
主 - 調用方法
Cursor wow = db.trying("Gold");
text = (TextView) findViewById(R.id.textView13);
String quantity = wow.getString(0); //
text.setText(quantity);
DB處理程序 - 方法
public Cursor trying(String vg){
String q = "SELECT quantity FROM " + TABLE_CONTACTS + " WHERE name=" + "'" + vg +"'";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(q, new String[] {vg});
if (cursor != null) {
cursor.moveToFirst();
}
return cursor;
}
我不明白你爲什麼創建下一個問題,而不是引用前面的錯誤,並給我n ext評論。 – Sajmon 2013-04-05 21:46:45