Java 如何反向读取sql数据库
嘿,伙计们,我有一个问题:我怎样才能从后面读取数据库? 这是我读取文件的方法:Java 如何反向读取sql数据库,java,android,sql,database,eclipse,Java,Android,Sql,Database,Eclipse,嘿,伙计们,我有一个问题:我怎样才能从后面读取数据库? 这是我读取文件的方法: 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 curs
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);
谢谢你的帮助!:) 您必须将查询方法的konstructor更改为Desc@Josef E。您能在这里帮助我吗?;)