title: How to add for loop values to an arraylist?
body: <p>I have an activity where in the values are fetched via JSON. The <code>for</code> loop is run. I am receiving all the values present in the fetched object from JSON. However, I want to append all the values to an <code>ArrayList</code>, i.e. <code>image_urls</code>. Could any one please help me?</p>
  
  <pre><code>public class AndroidJSONParsingActivity extends ListActivity {
  
      private static String url = "http://www.ttt.com/album_pro/array_to_encode";
  
      JSONArray folio = null;
      ArrayList&lt;String&gt; urlList = new ArrayList&lt;String&gt;();
      public static ArrayList&lt;String&gt; image_urls = new ArrayList&lt;String&gt;();
  
      @SuppressLint("NewApi")
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                  .permitAll().build();
          StrictMode.setThreadPolicy(policy);
  
          JSONParser jParser = new JSONParser();
          try {
              JSONObject json = jParser.getJSONFromUrl(url);
              // Log.v("URL",json.toString());
  
              JSONObject seo = json.getJSONObject("SEO");
              // Log.v("seo",seo.toString());
              JSONArray folio = seo.getJSONArray("Folio");
              Log("ARRAY-FOLIO0" + folio);
  
              JSONArray image_urls1 = new JSONArray();
              String s1 = seo.getString("Folio");
              for (int i = 0; i &lt; folio.length(); i++) {
                  String m = folio.getString(i);
                  Log.v("M" + i, m);
                  image_urls.add(folio.getString(i) + ",");
                  Log("JSON-ARRAY--&gt;" + image_urls.add(folio.getString(i)));
              }
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      private void Log(String string) {
          Log.v("SEO-TEST", string);
  
      }
  }
  </code></pre>
  
  <p>Following is the logcat response I am getting</p>
  
  <pre><code>03-05 13:58:25.948: V/M0(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_a_grade_motor_school.html_a_poftfolio_2013_01_11.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M1(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arcticterntt_folio_portfolio_abc_tarps.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M2(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_able_scale.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M3(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_accent_aluminum_windows.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M4(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_access_health.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M5(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_acmeda__zipscreen.html_a_poftfolio_2013_01_11.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M6(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_aditya_birla_minerals.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M7(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_advanced_corporate_badges.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M8(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_aerotech_fans.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  03-05 13:58:25.948: V/M9(3241): http://www.tt.com/media/imagepath/portfolio_images/http_arctictern.tt_folio_portfolio_agriculture_victoria_services_.html_a_poftfolio_2013_01_10.png
  03-05 13:58:25.948: V/SEO-TEST(3241): JSON-ARRAY--&gt;true
  </code></pre>