Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (cur.getCount() > 0)
- {
- while (cur.moveToNext())
- {
- String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
- String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
- if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)
- {
- Cursor pCur = cr1.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);
- while (pCur.moveToNext())
- {
- //phoneContactList.add(name);
- Log.i("Contact List", name);
- Log.i("Contact List", id);
- getContactAccount(id,cr1);
- }
- pCur.close();
- }
- }
- }
- Cursor cursor = null;
- try {
- cursor = contentResolver.query(ContactsContract.RawContacts.CONTENT_URI,
- new String[]{ContactsContract.RawContacts.ACCOUNT_NAME, ContactsContract.RawContacts.ACCOUNT_TYPE},
- ContactsContract.RawContacts.CONTACT_ID +"=?",
- new String[]{String.valueOf(id)},
- null);
- if (cursor != null && cursor.getCount() >0)
- {
- cursor.moveToFirst();
- System.out.println("Account name is"+cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_NAME)));
- System.out.println("Account type is"+cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE)));
- cursor.close();
- }
- } catch (Exception e)
- {
- System.out.println(""+this.getClass().getName()+","+ e.getMessage());
- } finally
- {
- cursor.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement