Why is it null the elements of the array?
<p>I have an activity which has the following variable</p>

<pre><code>static CharSequence[] categories;
</code></pre>

<p>I'm receiving data using JSON</p>

<pre><code>try
{
    Thread cThread = new Thread(new getStringContent("http://192.168.0.101/curltest/getcategories.php"));
    cThread.start();            
}
catch(Exception ex)
{
    Log.i("YGo", ex.toString());
}

public class getStringContent implements Runnable {
        String suri;
        public getStringContent(String uri)
        {
            suri = uri; 
        }
        @Override
        public void run() {         
            try {
                JSONArray jsonArray = new JSONArray(getPageContent(suri));
                for (int i = 0; i &lt; jsonArray.length(); i++) {
                    JSONArray jsonSArray = jsonArray.getJSONArray(i);
                    categories = new CharSequence[jsonArray.length()];
                    categories[i] = jsonSArray.getString(0);
                    Log.i("YGo", categories[i].toString());
                }               
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                Log.e("YGo", e.toString());
            }
            dialog.dismiss();
        }       
    }
</code></pre>

<p>In the GUI thread if I click on the button, I would like to display the received data:</p>

<pre><code>for(int i=0; i&lt;categories.length; i++)
{
   Log.i("Ygo", String.valueOf(categories[i]));
   Log.i("Ygo", String.valueOf(selectedData[i]));
}
AlertDialog.Builder builder = new AlertDialog.Builder(PreferencesClass.this);
            builder.setTitle("Pick categories");

            builder.setMultiChoiceItems(categories, selectedData, onClickCatChooser);           
            builder.setPositiveButton("Ok", clickedOnClickCatOk);

            AlertDialog alert = builder.create();
            alert.show();
</code></pre>

<p>but in the <code>categories</code> variable I have <code>null,null,Data3</code>, instead of <code>Data1</code> and <code>Data2</code> I have only <code>null</code>. Why?</p>
