From eb956877451d387a68eddde1c487b3430f3a2900 Mon Sep 17 00:00:00 2001 From: Hemal Patel Date: Wed, 25 May 2016 18:00:18 -0700 Subject: [PATCH] Docs: Fixed an invalid initialization of ExampleProvider member in Content URI patterns docs sample Bug: 28679030 Change-Id: Ia8f30fa82dbbced9c177e39a61834f25d5b331b2 --- .../providers/content-provider-creating.jd | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/html/guide/topics/providers/content-provider-creating.jd b/docs/html/guide/topics/providers/content-provider-creating.jd index 7cd3d6998a18c..baa92e131dc74 100755 --- a/docs/html/guide/topics/providers/content-provider-creating.jd +++ b/docs/html/guide/topics/providers/content-provider-creating.jd @@ -409,25 +409,27 @@ page.title=Creating a Content Provider public class ExampleProvider extends ContentProvider { ... // Creates a UriMatcher object. - private static final UriMatcher sUriMatcher; -... - /* - * The calls to addURI() go here, for all of the content URI patterns that the provider - * should recognize. For this snippet, only the calls for table 3 are shown. - */ -... - /* - * Sets the integer value for multiple rows in table 3 to 1. Notice that no wildcard is used - * in the path - */ - sUriMatcher.addURI("com.example.app.provider", "table3", 1); + private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); - /* - * Sets the code for a single row to 2. In this case, the "#" wildcard is - * used. "content://com.example.app.provider/table3/3" matches, but - * "content://com.example.app.provider/table3 doesn't. - */ - sUriMatcher.addURI("com.example.app.provider", "table3/#", 2); + static { + /* + * The calls to addURI() go here, for all of the content URI patterns that the provider + * should recognize. For this snippet, only the calls for table 3 are shown. + */ + + /* + * Sets the integer value for multiple rows in table 3 to 1. Notice that no wildcard is used + * in the path + */ + sUriMatcher.addURI("com.example.app.provider", "table3", 1); + + /* + * Sets the code for a single row to 2. In this case, the "#" wildcard is + * used. "content://com.example.app.provider/table3/3" matches, but + * "content://com.example.app.provider/table3 doesn't. + */ + sUriMatcher.addURI("com.example.app.provider", "table3/#", 2); + } ... // Implements ContentProvider.query() public Cursor query(