在我的DATABASEADAPTER CLASS中,我编写了以下代码:
public Cursor getdetails(){
Cursor mCursor = db.query(CONTACTS_TABLE_NAME, new String[] {CONTACTS_COLUMN_ID,
CONTACTS_COLUMN_NAME, CONTACTS_COLUMN_PASSWROD, CONTACTS_COLUMN_EMAIL, CONTACTS_COLUMN_PHONE,CONTACTS_COLUMN_ADDRESS},
null, null, null, null, null);
return mCursor;
}
在我的List活动中,我完成了以下操作:
public class List extends Activity {
private LoginDataBaseAdapter database;
Cursor cursor;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
database = new LoginDataBaseAdapter(this);
database.open();
cursor = database.getdetails();
ListView lst = (ListView)findViewById(R.id.list);
@SuppressWarnings("deprecation")
ListAdapter adapter=new SimpleCursorAdapter(
this,
android.R.layout.simple_list_item_1,
cursor,
new String[] {cursor.getColumnName(cursor.getColumnIndex("CONTACTS_COLUMN_NAME"))},
new int[] {android.R.id.text1});
lst.setAdapter(adapter);
database.close();
}
}