简体   繁体   English

从Android中现有的内容提供商查询DISTINCT记录

[英]Querying DISTINCT records from existing content providers in android

I want Distinct records from content provider. 我想要来自内容提供商的不同记录。

My current code: 我当前的代码:

String[] projection= {"_id","address"};
Cursor address =  getContentResolver().query(android.provider.Telephony.Sms.Inbox.CONTENT_URI,projection, null, null,"address ASC");

You can add DISTINCT keyword in columns names in projection. 您可以在投影的列名称中添加DISTINCT关键字。 eg 例如

String[] projection= {"DISTINCT _id"};

Hope this will help you. 希望这会帮助你。

//use the DISTINCT before the name of the column //在列名称前使用DISTINCT

String[] projection= { "DISTINCT _id", "DISTINCT address"};

Cursor address =  getContentResolver().query(android.provider.Telephony.Sms.Inbox.CONTENT_URI,projection, null, null,"address ASC");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM