title: java substring raising an exception
body: <p>So i want to extract few characters from a string and then display it on Textview like this:</p>
  
  <pre><code>  Uri uri = Uri.parse("content://sms/inbox");
    Cursor crsr = getContentResolver().query(uri, null, null, null, null);
  
    startManagingCursor(crsr);
  
    String[] columns = new String[] { "address", "person", "date", "body",
        "type" };
  
    String address = "";
    String msg = "";
  
    ArrayList&lt;String&gt; conversations = new ArrayList&lt;String&gt;();
  
    if (crsr.getCount() &gt; 0) {
      while (crsr.moveToNext()) {
        address = crsr.getString(crsr.getColumnIndex(columns[0]));
        msg = crsr.getString(crsr.getColumnIndex(columns[3]));
        msg = msg.substring(1, 30) + "..."; // THIS CAUSES FATAL ERROR          
        conversations.add(address + "\n\n" + msg);          
      }
    }
  </code></pre>
  
  <p>It is pretty simple to use <code>substring</code> but i can't get why it is giving error and showing fatal errors, here is trace:</p>
  
  <pre><code>E/AndroidRuntime(14023):  FATAL EXCEPTION: main
  E/AndroidRuntime(14023):  java.lang.RuntimeException: Unable to start activity......
  E/AndroidRuntime(14023):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2313)
  E/AndroidRuntime(14023):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
  E/AndroidRuntime(14023):    at android.app.ActivityThread.access$600(ActivityThread.java:156)
  E/AndroidRuntime(14023):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
  E/AndroidRuntime(14023):    at android.os.Handler.dispatchMessage(Handler.java:99)
  E/AndroidRuntime(14023):    at android.os.Looper.loop(Looper.java:153)
  E/AndroidRuntime(14023):    at android.app.ActivityThread.main(ActivityThread.java:5336)
  E/AndroidRuntime(14023):    at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(14023):    at java.lang.reflect.Method.invoke(Method.java:511)
  E/AndroidRuntime(14023):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
  E/AndroidRuntime(14023):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
  E/AndroidRuntime(14023):    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:112)
  E/AndroidRuntime(14023):    at dalvik.system.NativeStart.main(Native Method)
  E/AndroidRuntime(14023):  Caused by: java.lang.StringIndexOutOfBoundsException: length=8; regionStart=1; regionLength=29
  E/AndroidRuntime(14023):    at java.lang.String.startEndAndLength(String.java:583)
  E/AndroidRuntime(14023):    at java.lang.String.substring(String.java:1464)
  E/AndroidRuntime(14023):    at com.sarfraznawaz.cleansms.MainActivity.onCreate(MainActivity.java:41)
  E/AndroidRuntime(14023):    at android.app.Activity.performCreate(Activity.java:5122)
  E/AndroidRuntime(14023):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
  E/AndroidRuntime(14023):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
  </code></pre>
  
  <p>Can anyone tell what's wrong with the line?</p>
  
  <pre><code>msg = msg.substring(1, 30) + "...";
  </code></pre>
  
  <p>Thanks</p>