我想将一个变量传递给我正在执行 SQLite 查询的 DBConnector.Java,但我不知道该怎么做,需要一些帮助。
public void onItemSelected(AdapterView<?> parent, View view, int position,long id)
{
spinnerRub.setSelection(position);
myRub = (String) spinnerRub.getSelectedItem();
}
现在我想将 myRub 传递给我拥有的 DBConnector.Java:
public List<String> getAllCapabilities1()
{
List<String> Caps = new ArrayList<String>();
String selectQuery = "SELECT Cap_Name FROM capability where Rub_ID = 'myRub'";
SQLiteDatabase database = this.dbOpenHelper.getReadableDatabase();
//Cursor cursor = database.rawQuery(selectQuery, null);
Cursor cursor = database.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst())
{
do
{
Caps.add(cursor.getString(0));
} while (cursor.moveToNext());
}
// closing connection
cursor.close();
database.close();
// returning lables
return Caps;
}
但我正在努力做到这一点,需要帮助。