求读取系统联系人的代码,最好可以修改及删除,多谢了,呵呵

ringerxyz 2010-09-02 10:43:22
惭愧啊,就这么点分了
...全文
40 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
vclongking 2010-09-02
  • 打赏
  • 举报
回复
//获得联系人
mCs = getContentResolver().query(Contacts.Phones.CONTENT_URI, null, null, null, null);
startManagingCursor(mCs);

String[] from = new String[] {Contacts.Phones.NAME, Contacts.Phones.NUMBER };
int[] to = new int[] {android.R.id.text1, android.R.id.text2};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, mCs, from, to);

setListAdapter(adapter);

//删除
SimpleCursorAdapter sa = (SimpleCursorAdapter)getListAdapter();
Cursor cursor = sa.getCursor();
cursor.moveToPosition((int)rowId);
String name = cursor.getString(cursor.getColumnIndex(Contacts.Phones.NAME));
Log.i(TAG, name);

getContentResolver().delete(Contacts.People.CONTENT_URI,
Contacts.People.NAME + "=?", new String[] { name });

基于列表的显示 。 网上这样的代码应该不少的啊。

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧