use of com.greendao.sql.DaoMaster in project AndroidDevelop by 7449.
the class MainActivity method init.
private void init() {
writableDatabase = new DaoMaster.DevOpenHelper(this, "greendao", null).getWritableDatabase();
DaoSession daoSession = new DaoMaster(writableDatabase).newSession();
//得到Dao的对象
userDao = daoSession.getUserDao();
// 遍历表中所有的数据
Cursor cursor = writableDatabase.query(userDao.getTablename(), userDao.getAllColumns(), null, null, null, null, null);
String[] from = { UserDao.Properties.UserName.columnName, UserDao.Properties.UserSex.columnName };
int[] id = { android.R.id.text1, android.R.id.text2 };
simpleCursorAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from, id, Adapter.NO_SELECTION);
listView.setAdapter(simpleCursorAdapter);
}
Aggregations