title: How to programmatically write data to a JSON file and then save it?
body: <p>I want to put the following data to my JSON file in Android Studio programmatically:</p>
  <pre><code>[{
      &quot;title&quot;:&quot;Olu4a такси&quot;,
      &quot;logo&quot;:&quot;Taxi/olu4a.jpg&quot;,
      &quot;color&quot;:&quot;#FFD916&quot;,
      &quot;textcolor&quot;:&quot;#000000&quot;,
      &quot;number&quot;:&quot;7000&quot;,
      &quot;bigimage&quot;:&quot;Taxi/olu4a_car.jpg&quot;,
      &quot;star&quot;:&quot;4.0&quot;
  },
  {
      &quot;title&quot;:&quot;Asia Express такси&quot;,
      &quot;logo&quot;:&quot;Taxi/d.jpg&quot;,
      &quot;color&quot;:&quot;#E7232D&quot;,
      &quot;textcolor&quot;:&quot;#ffffff&quot;,
      &quot;number&quot;:&quot;1616&quot;,
      &quot;bigimage&quot;:&quot;Taxi/asiaexpress.jpg&quot;,
      &quot;star&quot;:&quot;3.5&quot;
  }]
  </code></pre>
  <p>How can it be done?</p>
  <p>Example</p>
  <pre><code>JSONObject obj = new JSONObject(); 
  
  try { 
       obj.put(&quot;id&quot;, &quot;3&quot;); 
       obj.put(&quot;name&quot;, &quot;NAME OF STUDENT&quot;); 
       obj.put(&quot;year&quot;, &quot;3rd&quot;); 
       obj.put(&quot;curriculum&quot;, &quot;Arts&quot;); 
       obj.put(&quot;birthday&quot;, &quot;5/5/1993&quot;); 
  } catch (JSONException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
  } 
  </code></pre>