替代方案去precated人民类的Andr​​oid [英] Alternative for the deprecated People class in Android

查看:202
本文介绍了替代方案去precated人民类的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个程序来获取所有从电话簿中的联系人。

I was writing a program to retrieve all the contacts from the Phonebook.

下面去我的code里面的的onCreate

Here goes my code inside onCreate:

setContentView(R.layout.cursorlayout);
        ListView lv =(ListView)findViewById(R.id.cursorListView);
        String uriString = "content://contacts/people/";
        //Cursor myCursor = managedQuery(Uri.parse(uriString),null, null,null,null);
        Cursor myCursor = getContentResolver().query(People.CONTENT_URI, new String[] {People._ID, People.NAME, People.NUMBER}, null, null, null);
        startManagingCursor(myCursor);

        String from[] = new String[]{"People.NAME","People.NUMBER"};
        int to[] = new int[]{R.id.name,R.id.number};
        SimpleCursorAdapter s = new SimpleCursorAdapter(this,R.layout.simplecursorlayout,myCursor,from,to);
        lv.setAdapter(s);

不过,月食标志着类人为德precated.Infact父容器联系人本身就是pcated德$ P $。所以我的问题是,是否有任何替代此类,我可以使用?

However, eclipse marked the class "People" as deprecated.Infact the parent container "Contacts" itself is deprecated. So my question is, Is there any alternative to this class that I can use ?

推荐答案

ContactsContract 的!

这篇关于替代方案去precated人民类的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆