I have a file (ex.json) from which I take the data
{ "Adres": "ул. Курчатова, 10", "Comment": "В здании вокзала, на 1 и на 2 этаже", "Dobavil": "Сергей", "location": { "latitude": 48.474721, "longitude": 35.008587 }, "objectId": "sVjaCW0JV4" } doing so
public void update() StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(getAssets().open("ex.json"))); String temp; while ((temp = br.readLine()) != null) sb.append(temp); } catch (IOException e) { e.printStackTrace(); } finally { try { br.close(); // stop reading } catch (IOException e) { e.printStackTrace(); } } String myjsonstring = sb.toString(); try { JSONObject jsonObjMain = new JSONObject(myjsonstring); JSONArray jsonArray = jsonObjMain.getJSONArray("results"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = jsonArray.getJSONObject(i); String adres = jsonObj.getString("Adres"); String comment = jsonObj.getString("Comment"); String dobavil = jsonObj.getString("Dobavil"); JSONObject c = jsonArray.getJSONObject(i); JSONObject location = c.getJSONObject("location"); String lat = location.getString("latitude"); String lon = location.getString("longitude"); } } catch (JSONException e) { e.printStackTrace(); } } I want to know whether you can append data to the file? How do I write a string and an array of location? It might be easier to do it with a text file?