Reputation: 2237
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
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
Reputation: 106
Only to make simple and easy to build URIs safely.
Upvotes: 0
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.
Upvotes: 1