contentReceiver

原创 2017年07月23日 04:34:47
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Uri uri = ContactsContract.Contacts.CONTENT_URI;
        ContentResolver contentResolver =this.getApplicationContext().getContentResolver();
        Cursor cursor = contentResolver.query(uri,null,null,null,null);
        while (cursor.moveToNext()){
            String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
            String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
            Log.e("TAG", "getContact: --------------id:"+id+"  name:"+name);
        }
        cursor.close();
    }
}

相关文章推荐

内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:contentReceiver
举报原因:
原因补充:

(最多只允许输入30个字)