How can I append a query parameter to an existing URL?

后端 未结 7 1018
独厮守ぢ
独厮守ぢ 2020-12-24 00:05

I\'d like to append key-value pair as a query parameter to an existing URL. While I could do this by checking for the existence of whether the URL has a query part or a frag

7条回答
  •  失恋的感觉
    2020-12-24 00:42

    For android, Use: https://developer.android.com/reference/android/net/Uri#buildUpon()

    URI oldUri = new URI(uri);
    Uri.Builder builder = oldUri.buildUpon();
     builder.appendQueryParameter("newParameter", "dummyvalue");
     Uri newUri =  builder.build();
    

提交回复
热议问题