Android/Java - Best way to retrieve information from server?

时间:2015-05-24 21:34:02

标签: java android networking server

I have a server that stores a plain text file with a numerical value. The text file is constantly edited by the server every few minutes or so. What is the best way for an Android Client to retrieve the text file's contents?

2 个答案:

答案 0 :(得分:1)

The most efficient way would be using Volley library with a string request.

答案 1 :(得分:0)

Do something like this:

URL url = new URL("http://www.domain.com/file.txt");
URLConnection urlConnection = url.openConnection();
urlConnection.setConnectTimeout(1000);
InputStream is = urlConnection.getInputStream();