zoukankan      html  css  js  c++  java
  • Android ContentResolver 使用例子,读取联系人

    import android.app.ListActivity;
    import android.database.Cursor;
    import android.os.Bundle;
    import android.provider.Contacts.Phones;
    import android.widget.ListAdapter;
    import android.widget.SimpleCursorAdapter;

    public class ActivityMain extends ListActivity {
       
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, null); //获得一个ContentResolver并读取联系人列表
            startManagingCursor(c);  //托管结果
            ListAdapter adapter = new SimpleCursorAdapter(this,
                    android.R.layout.simple_list_item_2, c,
                            new String[] { Phones.NAME, Phones.NUMBER },
                            new int[] { android.R.id.text1, android.R.id.text2 });//生成适配器。
            setListAdapter(adapter); //绑定List
        }
       
    }

  • 相关阅读:
    奇技淫巧训练之一
    基于JS模块化现状谈谈选择ES6模块的原因
    vue-cli3项目搭建配置以及性能优化
    Umi + DvaJS
    ReactFragment用法介绍
    什么是纯函数
    10.25考试
    10.23考试
    线段树合并(雨天的尾巴 题解)
    10.21考试
  • 原文地址:https://www.cnblogs.com/finehappy/p/2054495.html
Copyright © 2011-2022 走看看