Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. if (cur.getCount() > 0)
  2. {
  3. while (cur.moveToNext())
  4. {
  5. String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
  6. String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
  7. if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)
  8. {
  9. Cursor pCur = cr1.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);
  10. while (pCur.moveToNext())
  11. {
  12. //phoneContactList.add(name);
  13. Log.i("Contact List", name);
  14. Log.i("Contact List", id);
  15.  
  16. getContactAccount(id,cr1);
  17.  
  18.  
  19.  
  20.  
  21.  
  22. }
  23. pCur.close();
  24. }
  25. }
  26.  
  27. }
  28.  
  29. Cursor cursor = null;
  30. try {
  31.  
  32. cursor = contentResolver.query(ContactsContract.RawContacts.CONTENT_URI,
  33. new String[]{ContactsContract.RawContacts.ACCOUNT_NAME, ContactsContract.RawContacts.ACCOUNT_TYPE},
  34. ContactsContract.RawContacts.CONTACT_ID +"=?",
  35. new String[]{String.valueOf(id)},
  36. null);
  37.  
  38.  
  39.  
  40.  
  41. if (cursor != null && cursor.getCount() >0)
  42. {
  43. cursor.moveToFirst();
  44.  
  45.  
  46. System.out.println("Account name is"+cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_NAME)));
  47. System.out.println("Account type is"+cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE)));
  48. cursor.close();
  49. }
  50. } catch (Exception e)
  51. {
  52.  
  53. System.out.println(""+this.getClass().getName()+","+ e.getMessage());
  54. } finally
  55. {
  56. cursor.close();
  57. }
  58.  
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement