use of android.content.UriMatcher in project mechanoid by robotoworks.
the class AbstractMovieDBContentProvider method createUriMatcher.
@Override
protected UriMatcher createUriMatcher() {
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = MovieDBContract.CONTENT_AUTHORITY;
matcher.addURI(authority, "movies", MOVIES);
matcher.addURI(authority, "movies/#", MOVIES_ID);
// User Actions
return matcher;
}
use of android.content.UriMatcher in project Sunshine-Version-2 by udacity.
the class WeatherProvider method buildUriMatcher.
/*
Students: Here is where you need to create the UriMatcher. This UriMatcher will
match each URI to the WEATHER, WEATHER_WITH_LOCATION, WEATHER_WITH_LOCATION_AND_DATE,
and LOCATION integer constants defined above. You can test this by uncommenting the
testUriMatcher test within TestUriMatcher.
*/
static UriMatcher buildUriMatcher() {
// I know what you're thinking. Why create a UriMatcher when you can use regular
// expressions instead? Because you're not crazy, that's why.
// All paths added to the UriMatcher have a corresponding code to return when a match is
// found. The code passed into the constructor represents the code to return for the root
// URI. It's common to use NO_MATCH as the code for this case.
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = WeatherContract.CONTENT_AUTHORITY;
// For each type of URI you want to add, create a corresponding code.
matcher.addURI(authority, WeatherContract.PATH_WEATHER, WEATHER);
matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/*", WEATHER_WITH_LOCATION);
matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/*/#", WEATHER_WITH_LOCATION_AND_DATE);
matcher.addURI(authority, WeatherContract.PATH_LOCATION, LOCATION);
return matcher;
}
use of android.content.UriMatcher in project android_frameworks_base by ParanoidAndroid.
the class UriMatcherTest method testContentUrisWithLeadingSlash.
@SmallTest
public void testContentUrisWithLeadingSlash() {
UriMatcher matcher = new UriMatcher(ROOT);
matcher.addURI("people", null, PEOPLE);
matcher.addURI("people", "/#", PEOPLE_ID);
matcher.addURI("people", "/#/phones", PEOPLE_PHONES);
matcher.addURI("people", "/#/phones/blah", PEOPLE_PHONES_ID);
matcher.addURI("people", "/#/phones/#", PEOPLE_PHONES_ID);
matcher.addURI("people", "/#/addresses", PEOPLE_ADDRESSES);
matcher.addURI("people", "/#/addresses/#", PEOPLE_ADDRESSES_ID);
matcher.addURI("people", "/#/contact-methods", PEOPLE_CONTACTMETH);
matcher.addURI("people", "/#/contact-methods/#", PEOPLE_CONTACTMETH_ID);
matcher.addURI("calls", null, CALLS);
matcher.addURI("calls", "/#", CALLS_ID);
matcher.addURI("caller-id", null, CALLERID);
matcher.addURI("caller-id", "/*", CALLERID_TEXT);
matcher.addURI("filter-recent", null, FILTERRECENT);
matcher.addURI("auth", "/another/path/segment", ANOTHER_PATH_SEGMENT);
checkAll(matcher);
}
use of android.content.UriMatcher in project platform_frameworks_base by android.
the class DocumentsProvider method attachInfo.
/**
* Implementation is provided by the parent class.
*/
@Override
public void attachInfo(Context context, ProviderInfo info) {
mAuthority = info.authority;
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
mMatcher.addURI(mAuthority, "root", MATCH_ROOTS);
mMatcher.addURI(mAuthority, "root/*", MATCH_ROOT);
mMatcher.addURI(mAuthority, "root/*/recent", MATCH_RECENT);
mMatcher.addURI(mAuthority, "root/*/search", MATCH_SEARCH);
mMatcher.addURI(mAuthority, "document/*", MATCH_DOCUMENT);
mMatcher.addURI(mAuthority, "document/*/children", MATCH_CHILDREN);
mMatcher.addURI(mAuthority, "tree/*/document/*", MATCH_DOCUMENT_TREE);
mMatcher.addURI(mAuthority, "tree/*/document/*/children", MATCH_CHILDREN_TREE);
// Sanity check our setup
if (!info.exported) {
throw new SecurityException("Provider must be exported");
}
if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grantUriPermissions");
}
if (!android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.readPermission) || !android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.writePermission)) {
throw new SecurityException("Provider must be protected by MANAGE_DOCUMENTS");
}
super.attachInfo(context, info);
}
use of android.content.UriMatcher in project platform_frameworks_base by android.
the class SearchIndexablesProvider method attachInfo.
/**
* Implementation is provided by the parent class.
*/
@Override
public void attachInfo(Context context, ProviderInfo info) {
mAuthority = info.authority;
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
mMatcher.addURI(mAuthority, SearchIndexablesContract.INDEXABLES_XML_RES_PATH, MATCH_RES_CODE);
mMatcher.addURI(mAuthority, SearchIndexablesContract.INDEXABLES_RAW_PATH, MATCH_RAW_CODE);
mMatcher.addURI(mAuthority, SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH, MATCH_NON_INDEXABLE_KEYS_CODE);
// Sanity check our setup
if (!info.exported) {
throw new SecurityException("Provider must be exported");
}
if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grantUriPermissions");
}
if (!android.Manifest.permission.READ_SEARCH_INDEXABLES.equals(info.readPermission)) {
throw new SecurityException("Provider must be protected by READ_SEARCH_INDEXABLES");
}
super.attachInfo(context, info);
}
Aggregations