0
我在sqlite數據庫中保存了edittext的值,並且我希望在點擊按鈕時可以在textview或listview中查看數據庫中的數據。如何在android中查看錶中的數據
我在sqlite數據庫中保存了edittext的值,並且我希望在點擊按鈕時可以在textview或listview中查看數據庫中的數據。如何在android中查看錶中的數據
in Button click listenerü將獲取所有數據的代碼寫入一個列表,然後將這個列表排列到您的列表視圖中。
下面的代碼被用於從源碼
public List<String> selectAll() {
List<String> list = new ArrayList<String>();
Cursor cursor = this.db.query(TABLE_NAME, new String[] { "name" },
null, null, null, null, "name desc");
if (cursor.moveToFirst()) {
do {
list.add(cursor.getString(0));<wbr>
} while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
return list;
}
獲取數據,以便進一步inforamtion見下面的鏈接