Skip to content

Instantly share code, notes, and snippets.

@barmgeat
Last active September 15, 2018 18:07
Show Gist options
  • Save barmgeat/3fb5278e262c5d6ed5ee7b30eb58d85d to your computer and use it in GitHub Desktop.
Save barmgeat/3fb5278e262c5d6ed5ee7b30eb58d85d to your computer and use it in GitHub Desktop.
public class AppProvider extends ContentProvider {
private static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
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
*/
uriMatcher.addURI("com.example.android.AppName", "words", 1);
/*
* Sets the code for a single row to 2. In this case, the "#" wildcard is
* used. "content://com.example.android.AppName/words/3" matches, but
* "content://com.example.android.AppName/words doesn't.
*/
uriMatcher.addURI("com.example.app.provider", "words/#", 2);
}
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment