我想使用下面的代碼將我的SQLite表的內容加載到ListView中。無法將我的SQLite數據加載到我的ListView中
myDbHelper = new DatabaseHelper(this);
Cursor cursor = getData();
CursorAdapter dataSource = new SimpleCursorAdapter(this, R.layout.menu_item, cursor, fields, null);
menuList.setAdapter(datasource); //My ListView
private Cursor getData() {
SQLiteDatabase db = myDbHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null,null, ORDER_BY);
return cursor;
}
當我運行應用程序時,它通過此代碼,然後引發錯誤。我是否使用正確的技術將數據添加到ListView?
什麼是錯誤/堆棧跟蹤? – 2011-02-14 16:36:14