I am very new to android development so forgive my ignorance. I need to be able to read some text from a remote webpage at say 15 minute intervals. The webpage itself contains just one word with no html tags or formatting. If this is possible if someone could point me in the right direction I'd appreciate it.
Thanks
Sure, try the following
try {
// Create a URL for the desired page
URL url = new URL("yoursite.com/thefile.txt");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str = in.readLine();
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
You might want to put "in.close()" in a finally {} clause, to make sure it always closes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With