Write data to local JSON file
<p>I have JSON file stored in assets folder. Reading from it is easy, but how can I write to it and if the data saved when exiting the app?</p>

<p>JSON:</p>

<pre><code>{
    "Home": [
        {
            "Task": "Lapup1",
            "Time": "14:00",
            "Date": "26/12/2016"
        },
        {
            "Task": "Lapup2",
            "Time": "17:00",
            "Date": "26/12/2016"
        },
        {
            "Task": "Lapup3",
            "Time": "15:00",
            "Date": "26/12/2016"
        }
    ]
}
</code></pre>

<p>Json Parser (Reading):</p>

<pre><code>public class JSONParser {

    ArrayList&lt;Task&gt; taskList;
    String json;

    public JSONParser(Context context) {
        taskList = new ArrayList&lt;Task&gt;();
        json = null;
        try {
            InputStream is = context.getAssets().open("Home.json");
            int size = is.available();
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer, "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void getJsonData(String type) {
        try {
            JSONObject obj = new JSONObject(json);
            JSONArray m_jArry = obj.getJSONArray("Home");

            for (int i = 0; i &lt; m_jArry.length(); i++) {
                JSONObject jo_inside = m_jArry.getJSONObject(i);
                Log.d("DTAG", jo_inside.getString("Task"));
                Log.d("DTAG", jo_inside.getString("Time"));
                Log.d("DTAG", jo_inside.getString("Date"));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
</code></pre>

<p>So how can I add something to my Home string?</p>