(UPDATE) This works on the emulator, but not on my HTC legend :(
I have the following method in my ListActivity and it does not return any values ββin Cursor (getCount = 0)
I canβt understand why. It doesn't matter which contact I click on 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(); } }
source share