title: How to put/get multiple JSONObjects to JSONArray?
body: <p>Is it possible to store multiple different <code>JSONObject</code>s into a single <code>JSONArray</code>? This is the structure, I want to store in a <code>JSONArray</code>.</p>
  
  <pre><code>[{"value1":1,"value2":900,"value3":1368349},{"value1":2,"value2":1900,"value3":136856},{"value1":3,"value2":600,"value3":136845}]
  </code></pre>
  
  <p>Here's the code where I am setting <code>JSONObject</code> and putting it into a <code>JSONArray</code></p>
  
  <pre><code>if(somecondition) {
    // putting values to json object
    jsonObj.put("value1", 1);
    jsonObj.put("value2", 900);
    jsonObj.put("value3", 1368349);
  }
  for(int i=0;i&lt;=jsonArray.length();i++){
    jsonArray.put(jsonObj);
    appObj.setJsonAlarmArray(jsonArray);
    // appObj is object of Application Class
    editor= sharedPrefs.edit();
    editor.putString("key", jsonArray.toString());
    System.out.println(jsonArray.toString());
    editor.commit();
  }
  </code></pre>
  
  <p>Using this code only the last value, which I am setting in JSON object Override to all objects. Any suggestions to achieve this?</p>