這是我的查詢選擇一個記錄並綁定到文本框
SELECT *
FROM articles
WHERE id >1
ORDER BY id ASC
LIMIT 1
我的要求很簡單。我只想選擇一個記錄並綁定到textViews。這是我迄今爲止所做的。
public Article oneRecord()
{
SQLiteDatabase db = this.getWritableDatabase();
Cursor c = db.rawQuery("SELECT * FROM articles WHERE id=3;", null);
if(c.moveToFirst()){
Article a= new Article();
a.setId(c.getString(c.getColumnIndex("id")));
a.setImage_url(c.getString(c.getColumnIndex("image_url")));
a.setTitle(c.getString(c.getColumnIndex("title")));
a.setBody(c.getString(c.getColumnIndex("body")));
}
return a;
}
你能告訴我們爲什麼你所嘗試的不起作用嗎? – personne3000 2014-09-19 07:23:54
預計會有更多代碼 – nobalG 2014-09-19 07:27:04
我可以使用Adapter或listView綁定到列表。我更新了我的問題,請檢查 – 2014-09-19 07:30:11