(UPDATE) This works on emulator but not on my HTC legend :(
I have the following method in my ListActivity and it is not returning any values in the Cursor (getCount=0)
I can't quite work out why. It doesn't matter which contact I click on in my List.
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Log.d(TAG,"onListItemClick");
//get Telephone number for entry and display in Toast
Uri phoneUri = ContentUris.withAppendedId(Phone.CONTENT_URI, id);
Log.d(TAG,String.valueOf(phoneUri));
String[] projection = new String[]{Phone.NUMBER};
//Get Cursor
Cursor phoneCursor = managedQuery(phoneUri, projection, null, null, null);
while(phoneCursor.moveToNext()){
String dspNumber;
String number = phoneCursor.getString(phoneCursor.getColumnIndexOrThrow(Phone.NUMBER));
if(number==""){
dspNumber = "No number found";
}else{
dspNumber = number;
}
Toast.makeText(this,dspNumber, 3000).show();
}
}