嘿伙计们我有一个问题:如何从后面读取数据库? 这是我阅读文件的方法:
Cursor cursor = myDb.getAllRows();
// Allow activity to manage lifetime of the cursor.
// DEPRECATED! Runs on the UI thread, OK for small/short queries.
startManagingCursor(cursor);
// Setup mapping from cursor to view fields:
String[] fromFieldNames = new String[]
{DBAdapter.KEY_KALO, DBAdapter.KEY_HYDRATE, DBAdapter.KEY_FAT, DBAdapter.KEY_PROTEIN ,DBAdapter.KEY_CAL};
int[] toViewIDs = new int[]
{R.id.item_Kalorien, R.id.item_KG_in_g, R.id.item_F_in_g, R.id.item_P_in_g,R.id.item_cal};
// Create adapter to may columns of the DB onto elemesnt in the UI.
SimpleCursorAdapter myCursorAdapter =
new SimpleCursorAdapter(
this, // Context
R.layout.item_tagebuch, // Row layout template
cursor, // cursor (set of DB records to map)
fromFieldNames, // DB Column names
toViewIDs // View IDs to put information in
);
// Set the adapter for the list view
ListView myList = (ListView) findViewById(R.id.listView1);
myList.setAdapter(myCursorAdapter);
感谢您的帮助!:)
答案 0 :(得分:0)
您必须将查询方法的构造函数更改为Desc