我想將一個變量傳遞給我的DBConnector.Java,我正在執行一個SQLite查詢,但我不知道該怎麼做,需要一些幫助。Android - 將變量傳遞給另一個活動
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;
}
但我在努力做到這一點,需要幫助。
使用共享首選項或意圖傳遞數據 – 2013-03-06 10:54:45