Flame of udun
Flame of udun

Reputation: 2237

Uri.builder vs string based url construction

Why would one use Uri.Builder when Urls can be constructed by simply concatenating string variables?

In which cases is advisable to use uribuilder over string variables and vice-versa?

Upvotes: 7

Views: 1897

Answers (3)

Uncaught Exception
Uncaught Exception

Reputation: 2179

Always prefer uribuilder over strings to build a uri as uribuilder has a lot of built-in validation to ensure that the given address is well-formed. Generally speaking, if you know that your uri is going to remain constant through out then you can go ahead and use a string but in the case when you will be often re-constructing your uri by changing/replacing fields, uribuilder is a must!

Upvotes: 1

Only to make simple and easy to build URIs safely.

Upvotes: 0

siva
siva

Reputation: 1858

Uri.Builder is a helper class using which you can offload the work of constructing various kinds of uri. It is always recommended to use this class instead of creating it yourself.

Uri.Builder

Upvotes: 1

Related Questions