From 86d27b262be1e67775b871e3f481c60dca1e543b Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Tue, 12 Oct 2021 12:00:31 -0700 Subject: Update call log provider docs to clarify how to use LIMIT. Clarifying that you CANNOT use LIMIT in the where clause and provide instructions on the right way to limit results. Test: Docs only change Bug: 175599057 Change-Id: Ib4e828fc33ae9b75e7a240e9f456907049fcc35e --- core/java/android/provider/CallLog.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 65132f033968..3663fa390daa 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -76,6 +76,25 @@ public class CallLog { /** * Contains the recent calls. + *

+ * Note: If you want to query the call log and limit the results to a single value, you should + * append the {@link #LIMIT_PARAM_KEY} parameter to the content URI. For example: + *

+     * {@code
+     * getContentResolver().query(
+     *                 Calls.CONTENT_URI.buildUpon().appendQueryParameter(LIMIT_PARAM_KEY, "1")
+     *                 .build(),
+     *                 null, null, null, null);
+     * }
+     * 
+ *

+ * The call log provider enforces strict SQL grammar, so you CANNOT append "LIMIT" to the SQL + * query as below: + *

+     * {@code
+     * getContentResolver().query(Calls.CONTENT_URI, null, "LIMIT 1", null, null);
+     * }
+     * 
*/ public static class Calls implements BaseColumns { /** -- cgit v1.2.3-59-g8ed1b