title: how to get substring in Android?
body: <p>I am  trying to get last subString from String, As I have a file name tulips.jpg how can I get only .jpg using substring method?</p>
  
  <p>I have used: </p>
  
  <pre><code>String Main_String =  dsfdsf.jpg or dfdfgfhfghgh.jpg or dsfsdfgdgsdg.jpg; 
  
  (can have any length, not fixed length)
  
  String str_jpg = Main_String.substring(1, Main_String.length());
  </code></pre>
  
  <p>/////////////////////</p>
  
  <pre><code>for(int i=0; i &lt; folderResponse.getPropertyCount(); i++) 
          {
              SoapObject SingleFolder = (SoapObject)folderResponse.getProperty(i);
  
          ID = Integer.parseInt(SingleFolder.getProperty(0).toString());
          KEY_SUBFOLDERNAME = SingleFolder.getProperty(1).toString();
          KEY_SUBJECTTYPE = SingleFolder.getProperty(3).toString();
  
              String[] str = KEY_SUBFOLDERNAME.split(".");
              for(int j = 0; j &lt; str.length; j++){
                    System.out.println(""+str[j]);
                    // you got all name here use what ever you want.
                    if(str[1] == "jpg"){
                          FolderList item = new FolderList(JPGimages[0], SingleFolder.getProperty(1).toString();, SingleFolder.getProperty(3).toString();;
                          Subfolderdata.add(item);
                      }  
  </code></pre>
  
  <p>Please suggest now</p>
  
  <p>Thanks</p>
  
  <pre><code>     03-01 16:28:17.115: I/FolderID(3254): 13002
  03-01 16:28:17.115: I/User_ID(3254): 1
  03-01 16:28:17.175: D/dalvikvm(3254): GC_FOR_ALLOC freed 16K, 5% free 7881K/8263K, paused 52ms
  03-01 16:28:17.175: I/dalvikvm-heap(3254): Grow heap (frag case) to 8.042MB for 262160-byte allocation
  03-01 16:28:17.255: D/dalvikvm(3254): GC_FOR_ALLOC freed 3K, 6% free 8134K/8583K, paused 70ms
  03-01 16:28:17.705: I/AllFolders(3254): anyType{FileFolderDetails=anyType{ID=13003; Name=Doc file; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13004; Name=My Pics; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13005; Name=Testing; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13075; Name=satnam; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13080; Name=Saini; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13084; Name=Jelly; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13092; Name=pushie; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13096; Name=Jarnail_Testing; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13099; Name=amarjeet; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13101; Name=Kuta; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13103; Name=tajmehal; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13105; Name=TextArea; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13107; Name=TextArea1; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13109; Name=TextArea2; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13115; Name=TextArea3; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13121; Name=TextArea5; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13124; Name=Check Char; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13128; Name=amitestinggggg; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13132; Name=kkk; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13136; Name=hhhhhhhhhhhhhhhhhh; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13140; Name=ravitevffvvgfdcvgbgvf; URL=anyType{}; SubjectType=Folder; }; FileFolderDetails=anyType{ID=13002; Name=Capture.PNG; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Capture1.PNG; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Chrysanthemum.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Content4Work.pdf; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Desert.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=DMS_Drag_and_Drop(2).doc; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=groups.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Jellyfish.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Koala.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Lighthouse.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=office.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Penguins.jpg; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Rohit.docx; URL=Tulips.jpg; SubjectType=File; }; FileFolderDetails=anyType{ID=13002; Name=Tulips.jpg; URL=Tulips.jpg; SubjectType=File; }; }
  03-01 16:28:17.725: W/System.err(3254): java.lang.ArrayIndexOutOfBoundsException: length=0; index=1
  03-01 16:28:17.725: W/System.err(3254):     at com.web.dms.Files_Folders_Activity.subfolderTreedata(Files_Folders_Activity.java:106)
  03-01 16:28:17.725: W/System.err(3254):     at com.web.dms.Files_Folders_Activity.onCreate(Files_Folders_Activity.java:56)
  03-01 16:28:17.735: W/System.err(3254):     at android.app.Activity.performCreate(Activity.java:4465)
  03-01 16:28:17.735: W/System.err(3254):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
  03-01 16:28:17.735: W/System.err(3254):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
  03-01 16:28:17.735: W/System.err(3254):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
  03-01 16:28:17.735: W/System.err(3254):     at android.app.ActivityThread.access$600(ActivityThread.java:122)
  03-01 16:28:17.735: W/System.err(3254):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
  03-01 16:28:17.735: W/System.err(3254):     at android.os.Handler.dispatchMessage(Handler.java:99)
  03-01 16:28:17.735: W/System.err(3254):     at android.os.Looper.loop(Looper.java:137)
  03-01 16:28:17.745: W/System.err(3254):     at android.app.ActivityThread.main(ActivityThread.java:4340)
  03-01 16:28:17.745: W/System.err(3254):     at java.lang.reflect.Method.invokeNative(Native Method)
  03-01 16:28:17.745: W/System.err(3254):     at java.lang.reflect.Method.invoke(Method.java:511)
  03-01 16:28:17.745: W/System.err(3254):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  03-01 16:28:17.755: W/System.err(3254):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  03-01 16:28:17.779: W/System.err(3254):     at dalvik.system.NativeStart.main(Native Method)
  03-01 16:30:37.056: D/AndroidRuntime(3283): Shutting down VM
  03-01 16:30:37.066: W/dalvikvm(3283): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
  03-01 16:30:37.077: E/AndroidRuntime(3283): FATAL EXCEPTION: main
  03-01 16:30:37.077: E/AndroidRuntime(3283): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3909)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.ActivityThread.access$1300(ActivityThread.java:122)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1184)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.os.Handler.dispatchMessage(Handler.java:99)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.os.Looper.loop(Looper.java:137)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.ActivityThread.main(ActivityThread.java:4340)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at java.lang.reflect.Method.invokeNative(Native Method)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at java.lang.reflect.Method.invoke(Method.java:511)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at dalvik.system.NativeStart.main(Native Method)
  03-01 16:30:37.077: E/AndroidRuntime(3283): Caused by: java.lang.NullPointerException
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
  03-01 16:30:37.077: E/AndroidRuntime(3283):     ... 11 more
  03-01 16:30:46.506: D/dalvikvm(3315): GC_FOR_ALLOC freed 58K, 4% free 6909K/7171K, paused 52ms
  03-01 16:30:46.517: I/dalvikvm-heap(3315): Grow heap (frag case) to 7.309MB for 488976-byte allocation
  03-01 16:30:46.656: D/dalvikvm(3315): GC_CONCURRENT freed 1K, 4% free 7385K/7687K, paused 4ms+3ms
  03-01 16:30:47.206: D/gralloc_goldfish(3315): Emulator without GPU emulation detected.
  03-01 16:30:47.356: W/TextLayoutCache(3315): computeValuesWithHarfbuzz -- need to force to single run
  03-01 16:30:52.366: D/InputEventConsistencyVerifier(3315): KeyEvent: ACTION_UP but key was not down.
  03-01 16:30:52.366: D/InputEventConsistencyVerifier(3315):   in android.widget.EditText@41051d18
  03-01 16:30:52.366: D/InputEventConsistencyVerifier(3315):   0: sent at 20208706000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=20208706, downTime=20208634, deviceId=0, source=0x101 }
  03-01 16:30:53.956: I/LoginDetail(3315): Username jarnail@sassypuma.comPassword admin
  03-01 16:30:54.036: D/dalvikvm(3315): GC_FOR_ALLOC freed 72K, 3% free 7633K/7815K, paused 44ms
  03-01 16:30:54.356: I/myLogin(3315): 1
  03-01 16:30:54.726: D/dalvikvm(3315): GC_CONCURRENT freed 362K, 7% free 7694K/8199K, paused 29ms+6ms
  03-01 16:30:55.026: I/AllFolders(3315): anyType{TreeData=anyType{ID=13002; FolderName=My Drive; ParentID=0; CreatedBy=1; }; TreeData=anyType{ID=13006; FolderName=Testing1; ParentID=0; CreatedBy=1; }; TreeData=anyType{ID=13007; FolderName=Testing123; ParentID=0; CreatedBy=1; }; }
  03-01 16:30:55.506: D/dalvikvm(3315): GC_CONCURRENT freed 362K, 7% free 7767K/8263K, paused 24ms+7ms
  03-01 16:30:55.886: W/IInputConnectionWrapper(3315): finishComposingText on inactive InputConnection
  03-01 16:30:57.246: I/FolderID(3315): 13002
  03-01 16:30:57.246: I/User_ID(3315): 1
  03-01 16:30:57.297: D/dalvikvm(3315): GC_FOR_ALLOC freed 17K, 5% free 7880K/8263K, paused 48ms
  03-01 16:30:57.297: I/dalvikvm-heap(3315): Grow heap (frag case) to 8.041MB for 262160-byte allocation
  03-01 16:30:57.356: D/dalvikvm(3315): GC_FOR_ALLOC freed 3K, 6% free 8133K/8583K, paused 52ms
  </code></pre>