What is the default Account Type / Name for contacts on Android Contact Application?

后端 未结 3 1810
感动是毒
感动是毒 2020-12-03 11:42

I would like to read contacts from ContactsContract API which belongs only to Phone / SIM and would like to avoid contacts synced from other apps like facebook and gmail. I

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 11:58

    I solved this problem.

    Account[] accountList = AccountManager.get(this).getAccounts();
    
    String accountSelection = "";
    for(int i = 0 ; i < accountList.length ; i++) {
      if(accountSelection.length() != 0)
        accountSelection = accountSelection + " AND ";
      accountSelection = accountSelection + ContactsContract.Groups.ACCOUNT_TYPE + " != '" +  accountList[i].type + "'";
    }
    

提交回复
热议问题