I have created a listview which displays all the people in the database. But how do I get the row id of the one I select so I can pass that infomation to the next activity.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.load_game1);
listContent = (ListView)findViewById(R.id.contentlist);
mDbAdapter = new DbAdapter(this);
mDbAdapter.open();
Cursor cursor = mDbAdapter.fetchAll();
startManagingCursor(cursor);
String[] from = new String[]{DbAdapter.KEY_NAME, DbAdapter.KEY_ROWID};
int[] to = new int[]{R.id.text};
cursorAdapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
listContent.setAdapter(cursorAdapter);
mDbAdapter.close();
}
Which displays
displays http://i.minus.com/iGEtGKGyF1Wgc.png
Now I want to click on a name get that row id from the database.
Use
setOnItemClickListeneron yourListviewthen you will get the id of the selected item (item id start from 0 but Database _id column is start from 1 so you should sendid+1, please confirm this).And send the id using intents.