title: change a value of a Name() within a JSON Object Android
body: <p>Hi i have a <code>JSONObject</code> that i have turned into an <code>Array</code> looped through that array for a variable to see if it exists if not create one i need to then write this back to the array then back into the <code>JSON Object</code> heres hat i have got so far but can't quite figure out how to write values back to a <code>JSON Object</code>?</p>
  
  <pre><code>public static void updateLocalDataWithObject(Context activityContext, JSONObject fullNetworkDataFromFile) throws JSONException{
  
               JSONObject fullNetworkfile = fullNetworkDataFromFile.getJSONObject("data");
               JSONObject tempUserDict = fullNetworkfile.getJSONObject("user");
               String user_pref_club = tempUserDict.getString("primary_club_id");
               Log.v("globals", "3.)user_pref_club = " + user_pref_club);
               JSONObject userClubsDict = fullNetworkfile.getJSONObject("user_clubs");
               Log.v("globals", "userClubsDict = " + userClubsDict);
  
               if(userClubsDict.length()!= 0){
  
                   JSONArray userClubsDictKeys = new JSONArray();          
                   userClubsDictKeys=userClubsDict.names();
  
                   ArrayList&lt;String&gt; stringArray = new ArrayList&lt;String&gt;();
                   for(int i = 0, count = userClubsDictKeys.length(); i&lt; count; i++)
                   {
                       try {
                           JSONObject jsonObject = userClubsDictKeys.getJSONObject(i);
                           stringArray.add(jsonObject.toString());
                       }
                       catch (JSONException e) {
                           e.printStackTrace();
                       }
                   }
  
                   for(String myString : stringArray){
                       Log.v("globals", "myString = " + myString);
  
                   }
  
                   Log.v("globals", "ARRAY userClubsDictKeys = " + userClubsDictKeys);
                   String clubID = userClubsDictKeys.getString(0);
                   Log.v("globals", "clubID = " + clubID);
  
                   if(user_pref_club =="" || (userClubsDictKeys.getString(0) == null)) user_pref_club = clubID; 
  </code></pre>
  
  <p>heres what gets logged out. i can't show the full data because its sensitive and have been instructed not to post it. but what im trying to do is write the vale of clubID to a new keyvalue pair in a JSONArray and then back to a JSONObject</p>
  
  <pre><code>03-01 12:00:51.269: V/globals(1085): ARRAY userClubsDictKeys = ["6496","16885"]
  03-01 12:00:51.269: V/globals(1085): clubID = 6496
  
  
               } 
  </code></pre>