title: Android Storing Nested JSON Object to ArrayList MultiLevel ExpandableListview
body: <p>I have a nested json data and multilevel expandablelistview. The JSON data is looks like this :</p>
  
  <pre><code>[
      {
          "DivisionID": "2c0e9dc1-a6a7",
          "DivisionName": "Tyuio",
          "SubDivision": [
              {
                  "SubDivisionID": "70c3ac53-eec6",
                  "SubDivisionName": "FM2222",
                  "Vehicle": [
                      {
                          "Nopol": "00571564",
                          "LastUpdate": "Oct 10 2010 10:10AM",
                          "LastSpeed": 0,
                          "LastLon": 106.82176
                          "Location": "KNOWHERE"
                      },
                      { 
                          "Nopol": "352848020936627",
                          "LastUpdate": "Oct 10 2010 10:10AM",
                          "LastSpeed": 0,
                          "LastLon": 10124.228
                          "Location": "KNOWHERE2"
                      }
                  ]
              }
          ]
      }
  ]
  </code></pre>
  
  <p>this is how i parsing the json data and is working <strong>(EDIT)</strong>:</p>
  
  <pre><code>protected ArrayList&lt;Product&gt; doInBackground(String... args) {
  // Building Parameters
  
  List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  
  ServiceHandler sh = new ServiceHandler();   
  // Making a request to url and getting response
  String jsonStr = sh.makeServiceCall(URL_DIVI , ServiceHandler.GET);
  
  try { 
      Divi = new JSONArray(jsonStr)
  
      pProductArrayList=new ArrayList&lt;Product&gt;();
  
      if (Divi != null) {
          // looping through All data
          for (int i = 0; i &lt; Divi.length(); i++) {
  
              JSONObject c = Divi.getJSONObject(i);
              // Storing each json item values in variable
              String divid = c.getString(DIV_ID);
              String divname = c.getString(DIV_NAME);
              pProductArrayList.add(DIV_NAME.getJSONObject(i).toString());
  
              if (c.getString(DIV_NAME).length() != 0)
              {
                  Log.d("Check", "filled");
              }else{
                  Log.d("Check", "unfilled");
              }
  
              pSubItemArrayList=new ArrayList&lt;SubCategory&gt;();
              SDiv = new JSONArray();
              if (SDiv != null) {
                  JSONArray SubDiv = c.getJSONArray("SubDivision");
                  for (int j=0; j&lt;SubDiv.length(); j++)
                  {
                      JSONObject sub = SubDiv.getJSONObject(j);
                      String subdivid = sub.getString(SUBDIV_ID);
                      String subdivname = sub.getString(SUBDIV_NAME);
                      pSubItemArrayList.add(new SubCategory(SUBDIV_NAME, mItemListArray)); 
                      if (sub.getString(SUBDIV_NAME).length() != 0)
                      {
                          Log.d("Check2", "subdvi_name filled");
                      }else{
                          Log.d("Check2", "subdvi_name unfilled");
                      }
                      ArrayList&lt;ItemList&gt; mItemListArray=new ArrayList&lt;ItemList&gt;();
  
                      Vehic = new JSONArray();
                      if (Vehic != null) {
                          JSONArray Vehc = sub.getJSONArray("Vehicle");
                          for (int k=0; k&lt;Vehc.length(); k++) 
                          {
                              JSONObject veh = Vehc.getJSONObject(k);
                              String nopol = veh.getString(TAG_NOPOL);
                              String location = veh.getString(TAG_LOCATION);
                              String longl = veh.getString(TAG_LONG);
                              mItemListArray.add(new ItemList(TAG_NOPOL,TAG_LOCATION,TAG_LONG));
                              if (veh.getString(TAG_NOPOL).length() != 0)
                              {
                                  Log.d("Check3", "nopol filled");
                              }else{
                                  Log.d("Check3", "nopol unfilled");
                              }
                          // creating new HashMap
                          HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                          // adding each child node to HashMap key =&gt; value
                          map.put(DIV_ID, divid);
                          map.put(DIV_NAME, divname);
                          map.put(SUBDIV_ID, subdivid);
                          map.put(SUBDIV_NAME, subdivname);
                          map.put(TAG_NOPOL, nopol);
                          map.put(TAG_LOCATION, location);
                          map.put(TAG_LONG, longl);
  
                          // adding HashList to ArrayList
                          diviList.add(map);
  </code></pre>
  
  <p>i am try to storing JSON into this ArrayList</p>
  
  <pre><code>private ArrayList&lt;Product&gt;pProductArrayList;
  private ArrayList&lt;SubCategory&gt;pSubItemArrayList;
  
  private static final String DIV_NAME= "DivisionName";
  private static final String SUBDIV_NAME = "SubDivisionName";
  private static final String TAG_NOPOL = "Nopol";
  private static final String TAG_LOCATION = "Location";
  private static final String TAG_LONG = "LastLon";
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);
  
      ArrayList&lt;ItemList&gt; mItemListArray=new ArrayList&lt;ItemList&gt;();
      mItemListArray.add(new ItemList(TAG_NOPOL, TAG_LOCATION,TAG_LONG));
  
      pSubItemArrayList=new ArrayList&lt;SubCategory&gt;();
      pSubItemArrayList.add(new SubCategory(SUBDIV_NAME, mItemListArray));    
  
      pProductArrayList=new ArrayList&lt;Product&gt;();
      pProductArrayList.add(new Product(DIV_NAME, pSubItemArrayList));
  </code></pre>
  
  <p><strong>Desired output :</strong></p>
  
  <pre><code>| Tyuio       |  &lt;-- parent list
       |  FM222      |  -- child list
            |  00571564   |   &lt;-- grandchild list #1
            |  KNOWHERE   |
            |  106.82176  |
            |  35284802   |   &lt;-- grandchild list #2
            |  KNOWHERE2  |
            |  10124.228  |
  </code></pre>
  
  <p>I have a problem to store and show the data into ArrayList. I don't get DivisionName (parent-list), SubdivisionName (child-list), and all of vehicle array (grandchild-list). This JSON data is dynamic. I can't finding out how to solve this problem. I have seen many online tutorials but those was not helpful for me. If I'm not very clear in my question apologies, just ask and I'll clarify.. Thank you in advance</p>