Uri.parse("content://provider/table?limit=5"); // or better via buildUpon() Uri audio = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; audio.buildUpon().appendQueryParameter("limit", "5");
private static Uri openMarketUrl(String packageName) { return Uri.parse("market://details") .buildUpon() .appendQueryParameter("id", packageName) .build(); }
private static Uri getGooglePlayUrl(String packageName) { return Uri.parse("https://play.google.com/store/apps/details") .buildUpon() .appendQueryParameter("id", packageName) .build(); }
public static Uri getMimeTypeUri(Uri contentUri, String mimeType) { if (!AUTHORITY.equals(contentUri.getAuthority())) { throw new IllegalArgumentException("Can only call this method for URIs within this authority!"); } if (contentUri.getQueryParameter("mime_type") != null) { throw new IllegalArgumentException("Can only call this method for not yet typed URIs!"); } return contentUri.buildUpon().appendQueryParameter("mime_type", mimeType).build(); }
// query code Uri queryUri = Uri.parse("content://what/ever/items"); queryUri = queryUri.buildUpon().appendQueryParameter("limit", "5").build(); // in ContentProvider String limit = queryUri.getQueryParameter("limit");
private static Uri getOriginUri(Uri uri) { Uri.Builder b = uri.buildUpon(); b.encodedPath(null); List<String> segments = uri.getPathSegments(); for (int i = 0; i < segments.size() - 1; i++) { b.appendEncodedPath(segments.get(i)); } return b.build(); }
/** * Converts the current board into a Uri. * @return a Uri that represents the current board. */ public Uri toUri() { Uri.Builder shareUri = SHARE_URI.buildUpon(); shareUri.appendQueryParameter(DATA_KEY, encodeBoard()); shareUri.appendQueryParameter(LOCKED_KEY, encodeLockedPositions()); return shareUri.build(); }
@Override public Uri insert(Uri uri, ContentValues values) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); long id = db.insert(APODContract.TABLE_NAME, null /* nullColumnHack */, values); notifyChange(); return uri.buildUpon().appendEncodedPath(String.valueOf(id)).build(); }
public static Uri getAttachmentUri(String accountUuid, long id) { return CONTENT_URI.buildUpon() .appendPath(accountUuid) .appendPath(Long.toString(id)) .build(); }
public static Uri getRawMessageUri(MessageReference messageReference) { return CONTENT_URI.buildUpon() .appendPath(messageReference.toIdentityString()) .build(); }
/** * Removes query parameter from an Uri, if present. * * @param uri The uri. * @param queryParameterName The name of the query parameter. * @return The uri without the query parameter. */ public static Uri removeQueryParameter(Uri uri, String queryParameterName) { Uri.Builder builder = uri.buildUpon(); builder.clearQuery(); for (String key : uri.getQueryParameterNames()) { if (!key.equals(queryParameterName)) { for (String value : uri.getQueryParameters(key)) { builder.appendQueryParameter(key, value); } } } return builder.build(); }
public static Uri getDeviceContentUri() { return getContentUri(TrayContract.Preferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "false") .build(); }
public static Uri getInternalDeviceContentUri() { return getContentUri(TrayContract.InternalPreferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "false") .build(); }
public static Uri getInternalUserContentUri() { return getContentUri(TrayContract.InternalPreferences.BASE_PATH).buildUpon() .appendQueryParameter("backup", "true") .build(); }
private ClipData buildClip() { Uri uri=PROVIDER .buildUpon() .appendEncodedPath(StreamProvider.getUriPrefix(AUTHORITY)) .appendEncodedPath("assets/FreedomTower-Morning.jpg") .build(); return(ClipData.newRawUri(getString(R.string.msg_photo), uri)); }
@Test @Config(manifest = Config.NONE) public void parse() { assertThat(Uri.parse(basePath).buildUpon().path(resourcePath).build()).isEqualTo(expectedUri); }
@Override public String getField(MessageInfoHolder source) { LocalMessage message = source.message; int accountNumber = message.getAccount().getAccountNumber(); return CONTENT_URI.buildUpon() .appendPath("delete_message") .appendPath(Integer.toString(accountNumber)) .appendPath(message.getFolder().getServerId()) .appendPath(message.getUid()) .build() .toString(); } }
@Override public boolean onLongClick(View view) { Uri uri=PROVIDER .buildUpon() .appendEncodedPath(StreamProvider.getUriPrefix(AUTHORITY)) .appendEncodedPath("assets/FreedomTower-Morning.jpg") .build(); ClipData clip=ClipData.newRawUri(getString(R.string.msg_photo), uri); View.DragShadowBuilder shadow=new ThumbDragShadow(); iv.startDragAndDrop(clip, shadow, Boolean.TRUE, View.DRAG_FLAG_GLOBAL|View.DRAG_FLAG_GLOBAL_URI_READ| View.DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION); return(true); }
@Override public boolean onLongClick(View view) { Uri uri=PROVIDER .buildUpon() .appendEncodedPath(StreamProvider.getUriPrefix(AUTHORITY)) .appendEncodedPath("assets/FreedomTower-Morning.jpg") .build(); ClipData clip=ClipData.newRawUri(getString(R.string.msg_photo), uri); View.DragShadowBuilder shadow=new ThumbDragShadow(); iv.startDragAndDrop(clip, shadow, Boolean.TRUE, View.DRAG_FLAG_GLOBAL|View.DRAG_FLAG_GLOBAL_URI_READ| View.DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION); return(true); }
@Test public void shouldHandleSchemeInsensitiveCase() { String[] schemes = { "http", "https", "HTTP", "HTTPS", "HTtP", }; for (String scheme : schemes) { Uri uri = URI_1.buildUpon().scheme(scheme).build(); assertThat(networkHandler.canHandleRequest(TestUtils.mockRequest(uri))).isTrue(); } }