联系人中的列无效
我计划为我的应用程序创建cursorjoiner。我想使用cursorjoiner 加入显示名称和电子邮件ID。我正在尝试Android 1.6。
当我查询电子邮件 ID 列表时,出现异常:
03-30 13:08:15.609: ERROR/AndroidRuntime(302): Caused by: java.lang.IllegalArgumentException: Invalid column person
我的代码如下:
String[] projection1 = new String[] {
People._ID,
People.DISPLAY_NAME
} ;
String[] projection2 = new String[] {
Contacts.ContactMethods.PERSON_ID,
Contacts.ContactMethods.DATA
} ;
Cursor cur = cr.query(People.CONTENT_URI, projection1, null, null, null);
Cursor emailCur = cr.query( Contacts.ContactMethods.CONTENT_EMAIL_URI,
projection2,
null, null, null);
我检查了文档,它说 PERSON_ID
是有效条目。
另外,如果我在查询中使用同一列作为参数,它就可以工作。
emailCur = cr.query( Contacts.ContactMethods.CONTENT_EMAIL_URI,
projection2,
Contacts.ContactMethods.PERSON_ID + " = ?",
new String[]{id}, null);
任何人都可以告诉我应该在投影中使用什么参数来实现这一目标。
I am planning to create cursorjoiner for my app. I would like to join the Display name and Email id using the cursorjoiner. I am trying on Android 1.6.
When I query for the Email Id list, I get an exception as :
03-30 13:08:15.609: ERROR/AndroidRuntime(302): Caused by: java.lang.IllegalArgumentException: Invalid column person
My code is as below
String[] projection1 = new String[] {
People._ID,
People.DISPLAY_NAME
} ;
String[] projection2 = new String[] {
Contacts.ContactMethods.PERSON_ID,
Contacts.ContactMethods.DATA
} ;
Cursor cur = cr.query(People.CONTENT_URI, projection1, null, null, null);
Cursor emailCur = cr.query( Contacts.ContactMethods.CONTENT_EMAIL_URI,
projection2,
null, null, null);
I checked the docs it says PERSON_ID
is a valid entry.
Also, if I use the same column as a parameter inside a query it works.
emailCur = cr.query( Contacts.ContactMethods.CONTENT_EMAIL_URI,
projection2,
Contacts.ContactMethods.PERSON_ID + " = ?",
new String[]{id}, null);
Can any one tell what parameter should I use in projection to achieve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
联系人 已弃用,请使用 ContactsContract 代替。
Contacts is depreciated, use ContactsContract instead.