title: How to append new Array in JSON file stored in android
body: <p>I have one JSON file in my app's data folder.</p>
  
  <pre><code> {
    "user": [
      {
        "identifier": "1",
        "name": "xyz",
        "contact": [
          {
            "contact": "123"
          },
          {
            "contact": "456"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>Now I want to add a new user at runtime like this.</p>
  
  <pre><code>{
    "user": [
      {
        "identifier": "1",
        "name": "xyz",
        "contact": [
          {
            "contact": "123"
          },
          {
            "contact": "456"
          }
        ]
      }
    ],
    "user": [
      {
        "identifier": "2",
        "name": "abc",
        "contact": [
          {
            "contact": "445"
          },
          {
            "contact": "789"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>For that, I have this code but it simply overrides the existing user.</p>
  
  <pre><code>String lastObject = getStringFronFile(new FileInputStream(file));
          try {
              JSONObject prevJSONObj = new JSONObject(lastObject);
              prevJSONObj.put("sticker_packs",newUserArray);
              writeJsonFile(file,prevJSONObj);
          }
          catch (Exception e) {
              Log.d("Json Error", e.toString());
          }
  </code></pre>
  
  <p><code>writeJsonFile</code> is a method for writing in the file.</p>
  
  <p>Any help will be appreciated.</p>