2014-10-27 256 views
1

如何從SIM卡無法獲得聯繫人列表?Android獲取聯繫人列表,但沒有SIM卡聯繫人

到目前爲止我的光標看起來像這樣

public final static Uri CONTENT = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; 
public final static String ID = ContactsContract.CommonDataKinds.Phone.CONTACT_ID; 
public final static String NAME = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME; 
public final static String NUMBER = ContactsContract.CommonDataKinds.Phone.NUMBER; 
public final static String PHOTO_URI = ContactsContract.CommonDataKinds.Photo.PHOTO_URI; 
public final static String STARRED = ContactsContract.CommonDataKinds.Phone.STARRED; 

String mSelectionClause = NAME + " IS NULL"; 
mOrderBy = NAME + " COLLATE LOCALIZED ASC"; 

Cursor cursor = getActivity().getContentResolver().query(CONTENT, null, mSelectionClause, null, mOrderBy); 

我應該怎麼添加到查詢刪除從結果SIM卡聯繫人?

+0

你檢查這篇文章? http://developer.android.com/training/contacts-provider/retrieve-names.html – 2014-10-27 09:44:06

+0

@OleksiiKropachov是的,但我找不到有關我的問題的任何信息 – Mariusz 2014-10-27 10:00:47

回答

1

我發現folution在

android showing both sim and phone contacts

剛剛添加

private final String excludeSim = ContactsContract.RawContacts.ACCOUNT_TYPE + " <> 'com.android.contacts.sim' AND " 
    + ContactsContract.RawContacts.ACCOUNT_TYPE + " <> 'com.anddroid.contacts.sim' AND " // HTC 
    + ContactsContract.RawContacts.ACCOUNT_TYPE + " <> 'vnd.sec.contact.sim' AND " 
    + ContactsContract.RawContacts.ACCOUNT_TYPE + " <> 'USIM Account' "; 
    ... 
    String mSelectionClause = NAME + " IS NULL AND " + excludeSim; 
相關問題