How to query from MEDIA provider with "group by" option?

Posted by gkshope on Stack Overflow See other posts from Stack Overflow or by gkshope
Published on 2010-06-03T10:52:37Z Indexed on 2012/03/22 23:29 UTC
Read the original article Hit count: 190

Filed under:
|

I'm a newbie to Android. Actually, I want to query data from Media provider with Content provider & content resolver.

c = mContent.query(CONTENT_URI,projection,where,null,null); 

My question is, how can I query data from media provider as below using a GROUP BY clause:

select DISTINCT _id, count(_id), _data FROM aaa_table WHERE _data LIKE "A" OR _data LIKE "B" GROUP BY _id;

I have tried setting projection and where as follows:

 final String[] projection = new String[] {
                "_id", 
                "COUNT ("+ _id +")" ,
                "_data" 
                }; 

and where:

_data LIKE "A" OR _data LIKE "B"

but, I couldn't find how to set the query option GROUP BY _id.

Please help me.

© Stack Overflow or respective owner

Related posts about android

Related posts about contentprovider