title: How to use structured query arguments for GROUP BY query using ContentResolver
body: <p>In android 30 it is recommended to use structured query arguments.
  I want to use <a href="https://developer.android.com/reference/android/content/ContentResolver#QUERY_ARG_SQL_GROUP_BY" rel="nofollow noreferrer">QUERY_ARG_SQL_GROUP_BY</a> with <code>ContentResolver</code> but its not working.</p>
  <p>I am running following query to fetch data rows with <code>MIMETYPE</code> equal to <code>ntactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE</code> or <code>ntactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE</code>.</p>
  <p>In data table if contact has email and phone number we get two rows with same <code>CONTACT_ID</code>.
  Now I want to use Group BY <code>CONTACT_ID</code> and its not working.
  Selection and sorting is working as expected but group by is not working I have to write for loop to remove rows with same <code>CONTACT_ID</code>.</p>
  <pre><code>    val projection =
        arrayOf(
          ContactsContract.Data.MIMETYPE,
          ContactsContract.Data.CONTACT_ID,
          ContactsContract.Data.DATA1,
          ContactsContract.Data.DISPLAY_NAME
        )
  
      val selectQuery =
        &quot;&quot;&quot;
          ${ContactsContract.Data.MIMETYPE} IN (
          '${ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE}',
          '${ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE}'
           )
        &quot;&quot;&quot;.trimIndent()
  
      val sortOrder =
        &quot;&quot;&quot;
          ${ContactsContract.Data.DISPLAY_NAME} GLOB '[A-Za-z]*' DESC,
          LTRIM(LTRIM(${ContactsContract.Data.DISPLAY_NAME}, '.'), '_')
          COLLATE NOCASE
          &quot;&quot;&quot;
      val bundle = Bundle().apply {
        putString(ContentResolver.QUERY_ARG_SQL_SELECTION, selectQuery)
        putString(ContentResolver.QUERY_ARG_SQL_SORT_ORDER, sortOrder)
        // This is not working.
        putString(ContentResolver.QUERY_ARG_SQL_GROUP_BY, ContactsContract.Data.CONTACT_ID)
      }
      
      context.contentResolver.query(ContactsContract.Data.CONTENT_URI, projection, bundle, null)
  </code></pre>