So i am a newbie to android.i am very much confused right now.tell me what is the difference between HTTPUrlConnection and HTTPClient And which is preferable while fetching the data from web
-
1HTTPUrlConnection is the new class which replace the HTTPClient class – Vinoth Vino Jul 02 '16 at 04:42
2 Answers
HttpClient is deprecated and should not be used for any new applications. HttpUrlConnection was originally meant to be it's replacement, it has fewer apis but is smaller and more lightweight. However, some attractive competitors have emerged for HttpUrlConnection, including okHttp, Retrofit and Volley (from square and google respectively).
Unless you have some specific needs from the library (intercepting requests and modifying the headers for example), I would recommend going with okHttp as it has a larger community and is more robust.
This SO post and this blog post do a good job describing your options.

- 1
- 1

- 1,662
- 1
- 12
- 16
If you're referring to HTTPClient available in Java SE (JDK 11 or newer), that is not present in Android Java but HTTPUrlConnection is available in the Android Java SDK.
However, the currently preferred way is using the "Volley" library as described by official documentation here.

- 190
- 1
- 10