我正在编写一个程序来检索电话簿中的所有联系人。
我的代码在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”本身。所以我的问题是,我可以使用这个类吗?