Android獲取聯絡人(一人多號)

2021-09-13 04:05:30 字數 1103 閱讀 9173

/**

* created on 2019/3/20.

* * @author dk

* 聯絡人的實體類

*/public class readcontactsutils

public listgetphonecontacts() , null, null, null);

if (cursorperson != null && cursorperson.movetofirst()) , contact_id + "=" + id, null, null);

if (datacursor != null && datacursor.movetofirst())

while (datacursor.movetonext());

}datacursor.close();

} while (cursorperson.movetonext());

}cursorperson.close();

return contactsmodels;

}}

public final cursor query (uri uri, string projection,string selection,string selectionargs, string sortorder)

uri : 上面我們提到了android提供內容的叫provider,那麼在android中怎麼區分各個provider?有提供聯絡人的,有提供等等。所以就需要有乙個唯一的標識來標識這個provider,uri就是這個標識android.provider.contactscontract.contacts.content_uri就是提供聯絡人的內容的位址,可惜這個內容提供者提供的資料很少。

projection : 真不知道為什麼要用這個單詞,這個引數告訴查詢要返回的列(column),比如contacts provider提供了聯絡人的id和聯絡人的name等內容,如果我們只需要name,那麼我們就應該使用:

projection=new string;

selection  :查詢where字句

selectionargs : 查詢條件屬性值

sortorder :結果排序規則

Android操作聯絡人

android系統中的聯絡人也是通過contentprovider來對外提供資料的,我們這裡實現獲取所有聯絡人 通過 號碼獲取聯絡人 新增聯絡人 使用事務新增聯絡人。獲取所有聯絡人 1.android系統中的聯絡人也是通過contentprovider來對外提供資料的 2.資料庫路徑為 data d...

Android操作聯絡人

一 聯絡人資料庫 聯絡人的資料庫檔案的位置 data data com.android.providers.contacts databases.contacts2.db 資料庫中重要的幾張表 1 contacts表 該錶儲存了所有的手機測聯絡人,每個聯絡人佔一行,該錶儲存了聯絡人的 contact...

android 聯絡人詳解

操作聯絡人工程需要許可權,不然會報錯。android聯絡人是用資料庫儲存的,資料庫結構如下 raw contacts表 主要儲存了每個聯絡個的唯一表示欄位 id欄位。data表 raw contact id就是raw contacts中的 id欄位,所有raw contact id值相同的都是 同乙...