StringIndexOutOfBoundsException in android
<p>I am getting the following error:</p>

<pre><code>    java.lang.StringIndexOutOfBoundsException: length=13243; regionStart=32; regionLength=-39
    at java.lang.String.startEndAndLength(String.java:593)
    at java.lang.String.substring(String.java:1474)
    at com.dict.XMLParser.getResultFromXML(XMLParser.java:63)
    at com.dict.InternetDictProvider.searchWord(InternetDictProvider.java:29)
    at com.dict.SearchDict$SearchOnline.doInBackground(SearchDict.java:130)
    at com.dict.SearchDict$SearchOnline.doInBackground(SearchDict.java:1)
    at android.os.AsyncTask$2.call(AsyncTask.java:264)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    at java.lang.Thread.run(Thread.java:856)
</code></pre>

<p>in the following code which typically gets results after parsing the XML page given as HttpResponse to a HttpGet :</p>

<pre><code>        retry:
        {
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet("http://oxforddictionaries.com/definition/"+query+"?q="+query);
            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            String meanings=parser.getResultFromXML(StringUtils.inputStreamToString(httpEntity.getContent()));
            if(meanings==null &amp;&amp; firstRetry)
            {
                firstRetry=false;
                query = query.substring(0, 1).toUpperCase() + query.substring(1);
                break retry;
            }
            else if(meanings==null &amp;&amp; !firstRetry)
                return query;
            result = query + ":" + meanings;
        }
</code></pre>
