I'm trying to parse json from a url. I successed to parse from one url, so I copied the json file and uploaded to my domain(diffrent url) but now I can't get any data from the json. I havn't chaned the code in the android app except of the url. Please Help.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build();
StrictMode.setThreadPolicy(policy);
TextView tv=(TextView)findViewById(R.id.textView1);
TextView wid = (TextView) findViewById(R.id.id);
TextView name = (TextView) findViewById(R.id.title);
TextView url = (TextView) findViewById(R.id.description);
JSONObject json = null;
String str = "";
HttpResponse response;
HttpClient myClient = new DefaultHttpClient();
HttpPost myConnection = new HttpPost("My Url~");
try {
response = myClient.execute(myConnection);
str = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(1>0)
tv.setText(str);
try{
JSONArray jArray = new JSONArray(str);
json = jArray.getJSONObject(0);
wid.setText(json.getString("id"));
name.setText(json.getString("title"));
url.setText(json.getString("description"));
} catch ( JSONException e) {
e.printStackTrace();
}
when I print str I see all the text from the JSON file, but when I try to use getJSONObject I don't get any of the data from the JSON file.