title: I am gettingTypeCasting issue in Spinner
body: <p>I just want get the selected item from the spinner and i want to assign that variable. Here i am getting <code>typecasting exception</code>.</p>
  
  <pre><code>try
  {
      int id1 = Integer.parseInt(sp.getSelectedItem().toString());//this line is wrong
  
      man.setMid(id1);
      man.setMname(name.getText().toString());
      db.updatemanager(man);
      Toast.makeText(ctx, "Now its updated",Toast.LENGTH_SHORT).show();   
  }
  catch(Exception e)
  {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>LogCat</p>
  
  <pre><code>12-22 04:27:27.774: E/AndroidRuntime(1781): FATAL EXCEPTION: main
  12-22 04:27:27.774: E/AndroidRuntime(1781): Process: com.draw.androidproject2, PID: 1781
  12-22 04:27:27.774: E/AndroidRuntime(1781): java.lang.NullPointerException
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at com.draw.androidproject2.DialogFragment.ManagerupdateFragment$1.onClick(ManagerupdateFragment.java:57)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at android.view.View.performClick(View.java:4438)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at android.view.View$PerformClick.run(View.java:18422)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at android.os.Handler.handleCallback(Handler.java:733)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at android.os.Handler.dispatchMessage(Handler.java:95)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at android.os.Looper.loop(Looper.java:136)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at java.lang.reflect.Method.invoke(Method.java:515)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  12-22 04:27:27.774: E/AndroidRuntime(1781):     at dalvik.system.NativeStart.main(Native Method)
  12-22 04:27:29.804: I/Process(1781): Sending signal. PID: 1781 SIG: 9
  </code></pre>
  
  <p>If i print the value using Log then I'am getting value.</p>
  
  <pre><code>Log.i(sp.getSelectedItem().toString());
  </code></pre>
  
  <p>And this is the Spinner code</p>
  
  <pre><code>db = new DatabaseConnection(getActivity());
           List &lt;Manager&gt; mgr = new ArrayList&lt;&gt;() ;
  
          mgr = db.getAll();
              adapter = new UpdateAdapter(ctx, mgr);
              sp.setAdapter(adapter);
  </code></pre>