0
我想从数据库中提取一对夫妇列,并添加那些微调,但我想该行的_id被隐藏在那里过的地方。取部分样本代码下面的例子:如何将SQLite ID附加到Android中的微调对象?
public void fillProfileSpinner()
{
String query = "SELECT _id,fruit_type,weight,colour FROM fruits;";
SQLiteDatabase profileDatabase = fruitCakes.database.getReadableDatabase();
Cursor cursor = profileDatabase.rawQuery(query, null);
startManagingCursor(cursor);
try {
cursor.moveToFirst();
do
{
String fruitType = cursor.getString(cursor.getColumnIndex("fruit_type"));
double weight = cursor.getString(cursor.getColumnIndex("weight"));
String colour = cursor.getInt(cursor.getColumnIndex("colour"));
fruitAdapter.add(colour + " " + weight + " " + fruit_type);
}
while(cursor.moveToNext());
}
catch(Exception e)
{
e.printStackTrace();
}
cursor.deactivate();
cursor.close();
profileDatabase.close();
}
我相信这就是我要找的,但是我觉得很困惑: Android Spinners, say I pull spinner selections from SQL, can I also add their SQL _id's to the spinner values?
我怎么能在那里得到的_id柱的地方,所以可以从微调对象中的某些方法访问?