[問題] 如何從SQLite提取資料?
有人知道怎麼從SQLite查詢資料之後,
再將資料sursor型別轉成字串進入演算嗎?
cursor = get(id);
public Cursor get(long rowId) throws SQLException{ // 查詢指定 ID 的資料
Cursor cursor= db.rawQuery("SELECT _id, data4 FROM table02 WHERE
_id="+rowId,null);
if (cursor != null && cursor.getCount() >= 0){
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1, // 包含一個資料項
cursor, // 資料庫的 Cursors 物件
new String[] {"data4"}, // data4 欄位
new int[] { android.R.id.text1}); // 與 data對應的元件
}
return cursor;
}
上面我是想以id來查詢table中的個別資料,
取出資料之後想要該怎麼將sursor轉成字串或者其他形式來使用?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.117.178.11
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):