title: How to edit the value of a json object and write it to a file in android
body: <p>Format of json data inside file is like,</p>
  
  <pre><code>{
    "data": {
    "id": 0,
    "amount": 0,
    "no": 0
    }
  }
  </code></pre>
  
  <p>I need to edit <code>id</code> of this file.</p>
  
  <p>I used following snippet to do so,</p>
  
  <pre><code>String configFileString = getStringFromFile(configFile.toString());
  JSONObject json = new JSONObject(configFileString);
  json.put("id", 2);
  
  JSONObject gg = new JSONObject();
  gg.put("id",json);
  
  writeJsonFile(configFile, gg.toString());
  </code></pre>
  
  <p>But the output is like,</p>
  
  <pre><code>{
    "data": {
      "data": {
      "id": 0,
      "amount": 0,
      "no": 0
      },
      "id": 2
    }  
  }
  </code></pre>
  
  <p>What modifications should I do in my code? Please help me with this</p>