Skip to content Skip to sidebar Skip to footer

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.

Solution 1:

You can add DISTINCT keyword in columns names in projection. e.g.

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

Hope this will help you.

Solution 2:

//use the DISTINCT before the name of the column

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

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

Post a Comment for "Querying Distinct Records From Existing Content Providers In Android"