android 获取通讯录记录列表

**
         * 获取通讯录记录列表
         * @return
         */
        public ArrayList<Contactor> getList(){
                Log.i(TAG, "getList");
                
                ArrayList<Contactor> list = new ArrayList<Contactor>();
                
                String[] columns = new String[] {Phones.NAME, Phones.NUMBER};
                
                Cursor cursor = context.getContentResolver().query(Phones.CONTENT_URI, columns, null, null, People.DEFAULT_SORT_ORDER);
                while (cursor.moveToNext()) {
                        Contactor bean = new Contactor();
                        bean.setName(cursor.getString(0));
                        bean.setPhone(cursor.getString(1));
                        list.add(bean);
                        
                        Log.d(TAG, "name:" + bean.getName());
                        Log.d(TAG, "phone:" + bean.getPhone());
                }
                cursor.close();
                
                return list;
        }

posted on 2010-08-12 23:24  lbeing  阅读(4176)  评论(0编辑  收藏  举报

导航