i found the following code which is supposed to let me read the directory contents of from a web host (my website in this case)
String urlStr = "http://2112design.com/tabs/drum_tabs";
URL url;
try {
url = new URL(urlStr);
java.net.URLConnection con = url.openConnection();
con.connect();
java.io.BufferedReader in =
new java.io.BufferedReader(new java.io.InputStreamReader(con.getInputStream()));
String line;
for (; (line = in.readLine()) != null; ) {
Log.d("MainActivity", "read from web "+line);
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
when i run this, con.connect(); fails with the error trace like this:
android.os.NetworkOnMainThreadException
android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
java.net.InetAddress.lookupHostByName(InetAddress.java:385)
it looks like there is some kind of permission problem StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
but when i use a web browser on the same device and go to that URL, it opens fine.
i'm not very good on the webby stuff, can someone please help, thanks