I have an API in php that sends data in JSON format. I made the following code that works fine when I am on Wi-Fi. But when I want to load data from the API, when I am on 3g, I get the following exception: JSONException: End of character 0 input from
I have no idea why it works on Wi-Fi, but it does not work on mobile Internet. My code is:
JSONObject json = getJSONfromURL("http://api.myurl.com/users.json"); JSONArray objects = json.getJSONArray("objects"); db.setLockingEnabled(false); db.beginTransaction(); for (int i = 0; i < objects.length(); i++) { JSONObject e = objects.getJSONObject(i); if(e.getString("UID") != "-1"){ ContentValues values = new ContentValues(); //DO DATABASE INSERT. REMOVED THIS CODE FOR READABILITY alldata_mProgressDialog.incrementProgressBy(1); } }
Can anyone help me out?
json android
harmjanr
source share