我正在编写一个程序来检索电话簿中的所有联系人。
这是我在 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);
但是,eclipse 将类“People”标记为已弃用。事实上,父容器“Contacts”本身已弃用。所以我的问题是,我可以使用这个类的替代方案吗?
最佳答案
它的 ContactsContract !
关于java - Android 中已弃用的 People 类的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9247093/