0
- 我如何獲得1個特定行從數據庫(由ID例如)
光標C = db.rawQuery(「SELECT * FROM測量WHERE _id = 1" , NULL);如何從SQLite數據庫獲取特定數據和在TextView的顯示它
??
- 怎樣在的EditText顯示呢?
光標C = db.rawQuery(「SELECT * FROM測量WHERE _id = 1" , NULL);如何從SQLite數據庫獲取特定數據和在TextView的顯示它
??
你可以試試這個
Cursor myCursor = db.rawQuery("SELECT * FROM measurements WHERE _id = 1", null);
String myEditTextValue = myCursor.getString(*ColumnIndexHere*);
EditText myEditText= (EditText) findViewById(R.id.*EditTextIdHere*);
myEditText.setText(myEditTextValue);
但是請注意,在Android上最好的做法是使用內容提供商。欲知更多詳情,請點擊這裏 https://www.youtube.com/watch?v=CKjFfcFelrI and this https://developer.android.com/guide/topics/providers/content-providers.html