Can some one explain how the cursor exactly works ? Or the flow of the following part of the code ? I know that this is sub activity and all but I did not understand how Cursor works exactly.
final Uri data = Uri.parse("content://contacts/people/");
final Cursor c = managedQuery(data, null, null, null, null);
String[] from = new String[] { People.NAME };
int[] to = new int[] { R.id.itemTextView };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.listitemlayout, c, from, to);
ListView lv = (ListView) findViewById(R.id.contactListView);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
c.moveToPosition(pos);
int rowId = c.getInt(c.getColumnIndexOrThrow("_id"));
Uri outURI = Uri.parse(data.toString() + rowId);
Intent outData = new Intent();
outData.setData(outURI);
setResult(Activity.RESULT_OK, outData);
finish();
}
});
Thanks.