I am trying to detect deployd, and I created a simple table to store data. The table is stored in
http:
like JSONArray. I can get data with the following code:
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
public static JSONArray readJsonFromUrl(String url) throws IOException, JSONException {
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONArray json = new JSONArray(jsonText);
return json;
} finally {
is.close();
}
}
public static void main(String[] args) throws IOException, JSONException {
JSONArray obj = readJsonFromUrl("http://localhost:2403/table");
}
My question is that this data is stored in the local host. Let's say I want to use this database in my Android application. Then obviously I can’t use
JSONArray obj = readJsonFromUrl("http://localhost:2403/table")
to get a json array. So how can I get this? I looked at the documentation and found nothing. Which link should I use instead of the local host: 2403 / table?
thanks
source
share