Java Code Examples for android.content.UriMatcher#addURI()
The following examples show how to use
android.content.UriMatcher#addURI() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HobbitProviderImpl.java From mobilecloud-15 with Apache License 2.0 | 6 votes |
/** * Helper method to match each URI to the ACRONYM integers * constant defined above. * * @return UriMatcher */ protected static UriMatcher buildUriMatcher() { // 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 rootURI. // It's common to use NO_MATCH as the code for this case. final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); // For each type of URI that is added, a corresponding code is // created. matcher.addURI(CharacterContract.CONTENT_AUTHORITY, CharacterContract.PATH_CHARACTER, CHARACTERS); matcher.addURI(CharacterContract.CONTENT_AUTHORITY, CharacterContract.PATH_CHARACTER + "/#", CHARACTER); return matcher; }
Example 2
Source File: WeatherProvider.java From Advanced_Android_Development with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: FileContentProvider.java From Cirrus_depricated with GNU General Public License v2.0 | 6 votes |
@Override public boolean onCreate() { mDbHelper = new DataBaseHelper(getContext()); String authority = getContext().getResources().getString(R.string.authority); mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(authority, null, ROOT_DIRECTORY); mUriMatcher.addURI(authority, "file/", SINGLE_FILE); mUriMatcher.addURI(authority, "file/#", SINGLE_FILE); mUriMatcher.addURI(authority, "dir/", DIRECTORY); mUriMatcher.addURI(authority, "dir/#", DIRECTORY); mUriMatcher.addURI(authority, "shares/", SHARES); mUriMatcher.addURI(authority, "shares/#", SHARES); mUriMatcher.addURI(authority, "capabilities/", CAPABILITIES); mUriMatcher.addURI(authority, "capabilities/#", CAPABILITIES); return true; }
Example 4
Source File: AcronymProvider.java From mobilecloud-15 with Apache License 2.0 | 6 votes |
/** * Helper method to match each URI to the ACRONYM integers * constant defined above. * * @return UriMatcher */ private static UriMatcher buildUriMatcher() { // 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 rootURI. // It's common to use NO_MATCH as the code for this case. final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); // For each type of URI that is added, a corresponding code is // created. matcher.addURI(AcronymContract.CONTENT_AUTHORITY, AcronymContract.PATH_ACRONYM, ACRONYMS); matcher.addURI(AcronymContract.CONTENT_AUTHORITY, AcronymContract.PATH_ACRONYM + "/#", ACRONYM); return matcher; }
Example 5
Source File: MultiprocessSharedPreferences.java From MultiprocessSharedPreferences with Apache License 2.0 | 6 votes |
@Override public boolean onCreate() { if (checkInitAuthority(getContext())) { mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_ALL, GET_ALL); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_STRING, GET_STRING); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_INT, GET_INT); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_LONG, GET_LONG); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_FLOAT, GET_FLOAT); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_BOOLEAN, GET_BOOLEAN); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_CONTAINS, CONTAINS); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_APPLY, APPLY); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_COMMIT, COMMIT); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_REGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER, REGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_UNREGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER, UNREGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER); mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_STRING_SET, GET_STRING_SET); return true; } else { return false; } }
Example 6
Source File: WeatherProvider.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Creates the UriMatcher that will match each URI to the CODE_WEATHER and * CODE_WEATHER_WITH_DATE constants defined above. * <p> * It's possible you might be thinking, "Why create a UriMatcher when you can use regular * expressions instead? After all, we really just need to match some patterns, and we can * use regular expressions to do that right?" Because you're not crazy, that's why. * <p> * UriMatcher does all the hard work for you. You just have to tell it which code to match * with which URI, and it does the rest automagically. Remember, the best programmers try * to never reinvent the wheel. If there is a solution for a problem that exists and has * been tested and proven, you should almost always use it unless there is a compelling * reason not to. * * @return A UriMatcher that correctly matches the constants for CODE_WEATHER and CODE_WEATHER_WITH_DATE */ public static UriMatcher buildUriMatcher() { /* * All paths added to the UriMatcher have a corresponding code to return when a match is * found. The code passed into the constructor of UriMatcher here 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. Preferably, these are * constant fields in your class so that you can use them throughout the class and you no * they aren't going to change. In Sunshine, we use CODE_WEATHER or CODE_WEATHER_WITH_DATE. */ /* This URI is content://com.example.android.sunshine/weather/ */ matcher.addURI(authority, WeatherContract.PATH_WEATHER, CODE_WEATHER); /* * This URI would look something like content://com.example.android.sunshine/weather/1472214172 * The "/#" signifies to the UriMatcher that if PATH_WEATHER is followed by ANY number, * that it should return the CODE_WEATHER_WITH_DATE code */ matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/#", CODE_WEATHER_WITH_DATE); return matcher; }
Example 7
Source File: MusicUriMatcher.java From Melophile with Apache License 2.0 | 5 votes |
private void buildUriMatcher() { uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); MusicMatchEnum[] enums = MusicMatchEnum.values(); for (MusicMatchEnum uriEnum : enums) { uriMatcher.addURI(MusicContract.CONTENT_AUTHORITY, uriEnum.path, uriEnum.code); } }
Example 8
Source File: AbstractVideoItemProvider.java From android-tv-leanback with Apache License 2.0 | 5 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = VideoItemContract.CONTENT_AUTHORITY; matcher.addURI(authority, "videoitem", VIDEOITEM); matcher.addURI(authority, "videoitem/#", VIDEOITEM__ID); return matcher; }
Example 9
Source File: LoaderThrottleSupport.java From V.FlyoutTest with MIT License | 5 votes |
/** * Global provider initialization. */ public SimpleProvider() { // Create and initialize URI matcher. mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(AUTHORITY, MainTable.TABLE_NAME, MAIN); mUriMatcher.addURI(AUTHORITY, MainTable.TABLE_NAME + "/#", MAIN_ID); // Create and initialize projection map for all columns. This is // simply an identity mapping. mNotesProjectionMap = new HashMap<String, String>(); mNotesProjectionMap.put(MainTable._ID, MainTable._ID); mNotesProjectionMap.put(MainTable.COLUMN_NAME_DATA, MainTable.COLUMN_NAME_DATA); }
Example 10
Source File: ResProvider.java From ExRecyclerViewLibrary with Apache License 2.0 | 5 votes |
@Override public boolean onCreate() { mOpenHelper = new DBOpenHelper(getContext()); sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); sUriMatcher.addURI(AUTHORITY, ImageMetaData.TABLE_NAME, IMAGE_SETS); sUriMatcher.addURI(AUTHORITY, ImageMetaData.TABLE_NAME + "/*", IMAGE_ITEM); return true; }
Example 11
Source File: SymbolProvider.java From ministocks with MIT License | 5 votes |
/** * Sets up a uri matcher for search suggestion and shortcut refresh queries. */ private static UriMatcher buildUriMatcher() { UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT, SHORTCUT_REFRESH); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT + "/*", SHORTCUT_REFRESH); return matcher; }
Example 12
Source File: GithubDataProvider.java From gito-github-client with Apache License 2.0 | 5 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = RepositoryContract.CONTENT_AUTHORITY; matcher.addURI(authority, RepositoryContract.PATH_REPOSITORY, REPOSITORIES); matcher.addURI(authority, ReferrerContract.PATH_REFERRERS, REFERRERS); matcher.addURI(authority, ViewsContract.PATH_VIEWS, VIEWS); matcher.addURI(authority, ClonesContract.PATH_CLONES, CLONES); matcher.addURI(authority, TrendingContract.PATH_TRENDING, TRENDING); matcher.addURI(authority, StargazersContract.PATH_STARGAZERS, STARGAZERS); matcher.addURI(authority, RepositoryContract.PATH_REPOSITORY_STARGAZERS, REPOSITORIES_STARGAZERS); matcher.addURI(authority, UserContract.PATH_USERS, USERS); return matcher; }
Example 13
Source File: WeatherProvider.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Creates the UriMatcher that will match each URI to the CODE_WEATHER and * CODE_WEATHER_WITH_DATE constants defined above. * <p> * It's possible you might be thinking, "Why create a UriMatcher when you can use regular * expressions instead? After all, we really just need to match some patterns, and we can * use regular expressions to do that right?" Because you're not crazy, that's why. * <p> * UriMatcher does all the hard work for you. You just have to tell it which code to match * with which URI, and it does the rest automagically. Remember, the best programmers try * to never reinvent the wheel. If there is a solution for a problem that exists and has * been tested and proven, you should almost always use it unless there is a compelling * reason not to. * * @return A UriMatcher that correctly matches the constants for CODE_WEATHER and CODE_WEATHER_WITH_DATE */ public static UriMatcher buildUriMatcher() { /* * All paths added to the UriMatcher have a corresponding code to return when a match is * found. The code passed into the constructor of UriMatcher here 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. Preferably, these are * constant fields in your class so that you can use them throughout the class and you no * they aren't going to change. In Sunshine, we use CODE_WEATHER or CODE_WEATHER_WITH_DATE. */ /* This URI is content://com.example.android.sunshine/weather/ */ matcher.addURI(authority, WeatherContract.PATH_WEATHER, CODE_WEATHER); /* * This URI would look something like content://com.example.android.sunshine/weather/1472214172 * The "/#" signifies to the UriMatcher that if PATH_WEATHER is followed by ANY number, * that it should return the CODE_WEATHER_WITH_DATE code */ matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/#", CODE_WEATHER_WITH_DATE); return matcher; }
Example 14
Source File: WeatherProvider.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Creates the UriMatcher that will match each URI to the CODE_WEATHER and * CODE_WEATHER_WITH_DATE constants defined above. * <p> * It's possible you might be thinking, "Why create a UriMatcher when you can use regular * expressions instead? After all, we really just need to match some patterns, and we can * use regular expressions to do that right?" Because you're not crazy, that's why. * <p> * UriMatcher does all the hard work for you. You just have to tell it which code to match * with which URI, and it does the rest automagically. Remember, the best programmers try * to never reinvent the wheel. If there is a solution for a problem that exists and has * been tested and proven, you should almost always use it unless there is a compelling * reason not to. * * @return A UriMatcher that correctly matches the constants for CODE_WEATHER and CODE_WEATHER_WITH_DATE */ public static UriMatcher buildUriMatcher() { /* * All paths added to the UriMatcher have a corresponding code to return when a match is * found. The code passed into the constructor of UriMatcher here 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. Preferably, these are * constant fields in your class so that you can use them throughout the class and you no * they aren't going to change. In Sunshine, we use CODE_WEATHER or CODE_WEATHER_WITH_DATE. */ /* This URI is content://com.example.android.sunshine/weather/ */ matcher.addURI(authority, WeatherContract.PATH_WEATHER, CODE_WEATHER); /* * This URI would look something like content://com.example.android.sunshine/weather/1472214172 * The "/#" signifies to the UriMatcher that if PATH_WEATHER is followed by ANY number, * that it should return the CODE_WEATHER_WITH_DATE code */ matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/#", CODE_WEATHER_WITH_DATE); return matcher; }
Example 15
Source File: AbstractVideoItemProvider.java From android-tv-leanback with Apache License 2.0 | 5 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = VideoItemContract.CONTENT_AUTHORITY; matcher.addURI(authority, "videoitem", VIDEOITEM); matcher.addURI(authority, "videoitem/#", VIDEOITEM__ID); return matcher; }
Example 16
Source File: ProviGenProvider.java From MultiChoiceAdapter with Apache License 2.0 | 5 votes |
@Override public boolean onCreate() { openHelper = new ProviGenOpenHelper(getContext(), this, databaseName, contracts.getVersionSum()); uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); for (ContractHolder contract : contracts) { uriMatcher.addURI(contract.getAuthority(), contract.getTable(), ITEM); uriMatcher.addURI(contract.getAuthority(), contract.getTable() + "/#", ITEM_ID); } return true; }
Example 17
Source File: DocumentsProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void registerAuthority(String authority) { mAuthority = 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); }
Example 18
Source File: ClipboardProvider.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public boolean onCreate() { final ClipboardHelper helper = getClipboardHelper(); if (helper == null) return false; mMatcher = new UriMatcher(UriMatcher.NO_MATCH); mMatcher.addURI(helper.getAuthority(), helper.getPath() + "/*", helper.getCode()); return true; }
Example 19
Source File: PreferencesProvider.java From igniter with GNU General Public License v3.0 | 4 votes |
public PreferencesProvider() { mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(AUTHORITY, PATH, CODE_PREFERENCES); }
Example 20
Source File: ContentProviderPOS.java From stockita-point-of-sale with MIT License | 4 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = ContractData.AUTHORITY; matcher.addURI(authority, ContractData.DIR_TRIGGER_ITEM_MASTER + "/#", TRIGGER_ITEM_ID); matcher.addURI(authority, ContractData.DIR_TRIGGER_ITEM_MASTER, TRIGGER_ITEM_ENTRY); matcher.addURI(authority, ContractData.DIR_ITEM_MASTER + "/#", ITEM_MASTER_ID); matcher.addURI(authority, ContractData.DIR_ITEM_MASTER, ITEM_MASTER_ENTRY); matcher.addURI(authority, ContractData.DIR_SALES_DETAIL_PENDING + "/#", SALES_DETAIL_PENDING_ID); matcher.addURI(authority, ContractData.DIR_SALES_DETAIL_PENDING, SALES_DETAIL_PENDING_ENTRY); return matcher; }