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;
}
しかし、私はそれをするのに苦労していて、助けが必要です。