title: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
body: <p>I have to develop one Android application. Here I am getting following error:</p>
  
  <pre><code>03-26 21:29:00.394: E/AndroidRuntime(684): FATAL EXCEPTION: main
  03-26 21:29:00.394: E/AndroidRuntime(684): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
  03-26 21:29:00.394: E/AndroidRuntime(684):  at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at java.util.ArrayList.get(ArrayList.java:311)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at com.xmlparsing.MainActivity.loadXMLData(MainActivity.java:303)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at com.xmlparsing.MainActivity.access$2(MainActivity.java:118)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at com.xmlparsing.MainActivity$GetXmlFiles.onPostExecute(MainActivity.java:369)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at com.xmlparsing.MainActivity$GetXmlFiles.onPostExecute(MainActivity.java:1)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at android.os.AsyncTask.finish(AsyncTask.java:417)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at android.os.AsyncTask.access$300(AsyncTask.java:127)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at android.os.Handler.dispatchMessage(Handler.java:99)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at android.os.Looper.loop(Looper.java:123)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at java.lang.reflect.Method.invokeNative(Native Method)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at java.lang.reflect.Method.invoke(Method.java:521)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  03-26 21:29:00.394: E/AndroidRuntime(684):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Here I have used below code:</p>
  
  <pre><code>String[] stockArrVideo = new String[Appscontent.Sub_arraylistvideo.size()];
  stockArrVideo = Appscontent.Sub_arraylistvideo.toArray(stockArrVideo);
  for (String s : stockArrVideo) {
      if (s.startsWith(number)) {
          String _Substring;
          _Substring = s.substring(1);
          if(_Substring.equals("")||_Substring == null) {
              _Substring = "No Records";
          }
          Appscontent.Sub_arraylistvideosub.add(_Substring);
      }
      h++;
  }           
  </code></pre>
  
  <p>If the data is empty, it means I have to display the "No Records" message. Otherwise display the correct data.</p>
  
  <pre><code>TextView mVideo = new TextView(this); 
  System.out.println(Appscontent.Sub_arraylistvideosub.get(j));
  mVideo.setText(Appscontent.Sub_arraylistvideosub.get(j));
  mVideo.setLayoutParams(textLayoutParams);
  mVideo.setBackgroundColor(Color.BLACK);
  </code></pre>
  
  <p>Here I have wrote the code for checking the empty data.</p>
  
  <p>What is causing this exception?</p>