Android contentprovider does not return Phone.NUMBER

(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(); } } 
+6
source share
1 answer

Add Read_contacts permission in the manifest.

0
source

Source: https://habr.com/ru/post/905410/


All Articles