Bui Quang Huy Bui Quang Huy - 14 days ago 6
JSON Question

Which better to get Json between Retrofit 2 and HttpUrlConnection

I know two of it can be used to send http request and get the response from the server, then we can parse into Json object if we want. So:


  • Which is the best way to send request and get response from the server,
    Retrofit 2
    or
    HttpUrlConnection
    ?

  • Which is advantage and disadvantage between them?


Answer

Retrofit 2 and Volley are both great networking libraries for modern Android apps, but each has its own strengths that are worth weighing for critical projects. Use Retrofit if your use-case is a standard REST API with JSON responses and not too many custom requirements in terms of caching, request prioritization, retries, etc. Use Volley if you have unusual / fine-grained requirements, or if you anticipate needing a lot of flexibility from your networking layer in the future at the cost of more code. Use neither if you're downloading large files or streaming -- for that, use DownloadManager instead.

Note: HttpClient is deprecated Now

Need More, Find it here