簡單的安卓通訊錄

2021-08-21 13:38:47 字數 863 閱讀 7915

第一次demo安卓專案,理解介面卡adapter的填充,sqlite。

(1)最重要的是介面卡填充:

//得到手機通訊錄聯絡人資訊

getphonecontacts();

//對資料進行適配

mlistview =(listview)findviewbyid(r.id.lv);

myadapter = new mylistadapter(this);

mlistview.setadapter(myadapter);

獲取手機聯絡人:

(首先獲取resolver,通過resolver.query方法執行,執行結果給cuser游標,使用movetotest方法掃瞄結果,cuser.getstring方法獲取欄位string型別,再放入arraylist,add方法新增.)

private void getphonecontacts() {

contentresolver resolver = mcontext.getcontentresolver();

// 獲取手機聯絡人

cursor phonecursor = resolver.query(phone.content_uri,phones_projection,null,null,null);

if (phonecursor != null) {

while (phonecursor.movetonext()) {

//得到手機號碼

string phonenumber = phonecursor.getstring(phones_number_index);

//當手機號碼為空的或者為空欄位 跳過當前迴圈

安卓讀取系統通訊錄

讀取安卓系統通訊錄 新增依賴 implementation com.qw soulpermission 1.3.0 主要 class mainactivity 先申請讀取系統通訊錄許可權,再進行讀取。private funreadcontactswithpermission override fun...

簡單的通訊錄

include include include define t 1 define f 1 typedef int status typedef char type nam typedef char type num typedef char type add struct list type na...

通訊錄簡單實現

姓名 性別 年齡 住址 利用構建乙個結構體來儲存資訊,結構體的大小根據所需來自行規定 typedef struct add add typedef struct addnode addnode 關於資訊儲存的方法,最簡單的兩種辦法就是鍊錶跟順序表的結構,簡單說呢就是兩種不同的對資料或者說結構體的應用...