Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ba1cb06 authored by Tom O'Neill's avatar Tom O'Neill
Browse files

ContentResolver.query() includes performance considerations

Mention the desirability of using "?"-substitution in the where clause,
and reemphasize the importance of using an explicit projection.

Change-Id: Iaa489d50db409f34e78bcd55253e5a4e53445cf2
parent d1265feb
Loading
Loading
Loading
Loading
+28 −16
Original line number Diff line number Diff line
@@ -173,13 +173,25 @@ public abstract class ContentResolver {
    }

    /**
     * <p>
     * Query the given URI, returning a {@link Cursor} over the result set.
     * </p>
     * <p>
     * For best performance, the caller should follow these guidelines:
     * <ul>
     * <li>Provide an explicit projection, to prevent
     * reading data from storage that aren't going to be used.</li>
     * <li>Use question mark parameter markers such as 'phone=?' instead of
     * explicit values in the {@code selection} parameter, so that queries
     * that differ only by those values will be recognized as the same
     * for caching purposes.</li>
     * </ul>
     * </p>
     *
     * @param uri The URI, using the content:// scheme, for the content to
     *         retrieve.
     * @param projection A list of which columns to return. Passing null will
     *         return all columns, which is discouraged to prevent reading data
     *         from storage that isn't going to be used.
     *         return all columns, which is inefficient.
     * @param selection A filter declaring which rows to return, formatted as an
     *         SQL WHERE clause (excluding the WHERE itself). Passing null will
     *         return all rows for the given URI.