Hi, If you want to your strategy (using deprecated classes), then make two changes:
Change 1: change the intent --- intentforcontact= new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI); Change 2: change the column index --- String Number = c.getString(c.getColumnIndex(Phones.NUMBER)); ========= But, you should not be using deprecated classes Regards Sarwar Erfan On Aug 2, 3:55 pm, "A N K ! T" <[email protected]> wrote: > //i am using this code for opening phone contacts. > intentforcontact= new > Intent(Intent.ACTION_PICK,Contacts.CONTENT_URI); > startActivityForResult(intentforcontact, PICK_CONTACT); > > //in this code am trying to get phone numbers of contact,,but not > getting any number.it is returning 23 fields but no one containing contact > numbers > @Override > protected void onActivityResult(int requestCode, int resultCode, > Intent data) { > // TODO Auto-generated method stub > super.onActivityResult(requestCode, resultCode, data); > switch(requestCode) { > case (1) : { > if (resultCode == Activity.RESULT_OK) { > try{ > Uri contactData = data.getData(); > Cursor c = managedQuery(contactData, null, null, null, null); > c.moveToFirst(); > > // String sr[]=c.getColumnNames(); > String > Number=c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); > .............. > help me to find out contact numbers of phone > > > > On Mon, Aug 2, 2010 at 2:56 PM, Sarwar Erfan <[email protected]> wrote: > > Cursor cx = > > getContentResolver().query(RawContacts.CONTENT_URI, > > new String[]{RawContacts._ID}, > > null, null, null); > > > if(cx.moveToFirst()){ > > do{ > > > Uri rawContactUri = > > ContentUris.withAppendedId(RawContacts.CONTENT_URI, cx.getLong(0)); > > Uri entityUri = Uri.withAppendedPath(rawContactUri, > > Entity.CONTENT_DIRECTORY); > > Cursor c = getContentResolver().query(entityUri, > > new String[]{RawContacts.SOURCE_ID, > > Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, > > Entity.MIMETYPE + "=? OR " + > > Entity.MIMETYPE + > > "=?", > > new String[] > > {ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, > > ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE}, > > null); > > try { > > String name = ""; > > String phoneNumber = ""; > > > while (c.moveToNext()) { > > String sourceId = c.getString(0); > > if (!c.isNull(1)) { > > String mimeType = c.getString(2); > > > if(mimeType.equals(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)) > > { > > name = c.getString(3); //this is the > > name > > } > > else > > > if(mimeType.equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) > > { > > phoneNumber = c.getString(3); > > } > > } > > } > > Log.d("CONTACT", name + " - " + phoneNumber); > > } finally { > > c.close(); > > } > > > }while(cx.moveToNext()); > > } > > > ============================ > > What exactly do you want to do? If you can specify more clearly (or > > show the code you did with Contacts.People, then may be I can suggest > > smaller code snippet. > > > Regards > > Sarwar Erfan > > > On Aug 2, 11:53 am, "A N K ! T" <[email protected]> wrote: > > > when i am using this class it is written there use contactscontract > > but > > > am not getting how to use this class to fetch contacts number from > > > phone..... > > > > -- > > > > A N K ! T...... > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > > A N K ! T...... -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

