countQuery

fun countQuery(context: Context, uri: Uri, selection: String? = null): Int

Counts the rows a content-provider query returns without exposing their contents.

Queries only the _id column so the collector learns a count (e.g. number of contacts) without reading actual records; any failure yields 0.

Privacy: returns only an aggregate count, never row data. The caller is responsible for having the permission the uri requires.

Return

Number of matching rows, or 0 on failure.

Parameters

context

Context providing the content resolver.

uri

Content URI to query.

selection

Optional SQL-style selection filter.