Uri.builder vs string building url

Why use Uri.Builder when Urls can be built simply by concatenating string variables?

When is it advisable to use uribuilder on top of string variables and vice versa?

+6
source share
3 answers

Uri.Builder is a helper class in which you can offload the work of creating different types of uri. It is always recommended that you use this class, rather than creating it yourself.

Uri.Builder

+1
source

Only for simple and easy creation of a URI is safe.

0
source

Always prefer uribuilder over strings to create uri, as uribuilder has many built-in validations to ensure that the given address is correctly formed. Generally speaking, if you know that your uri will remain constant, you can continue and use the line, but in the case when you will often rearrange your uri by changing / replacing fields, uribuilder is a must!

0
source

Source: https://habr.com/ru/post/989230/


All Articles