title: While running this code java.lang.nullpointerexception occured and force close the application
body: <hr>
  
  <pre><code>package com.example.minorproject;
  
  
  
  import android.os.Bundle;
  
  import android.app.Activity;
  
  import android.content.Intent;
  
  import android.database.sqlite.SQLiteDatabase;
  
  import android.view.Menu;
  
  import android.view.View;
  
  import android.widget.EditText;
  
  import android.widget.Toast;
  
  public class SignUp extends Activity
   {
  
      Intent i=null;
      boolean flag=false;
      SQLiteDatabase db=null;
      EditText tv1,tv2,tv3,tv4,tv5,tv6;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_sign_up);
  
          EditText tv1=(EditText)findViewById(R.id.name);
          EditText tv2=(EditText)findViewById(R.id.email);
          EditText tv3=(EditText)findViewById(R.id.mobile_no);
          EditText tv4=(EditText)findViewById(R.id.address);
          EditText tv5=(EditText)findViewById(R.id.blood_group);
          EditText tv6=(EditText)findViewById(R.id.password);
  
          db=openOrCreateDatabase("DATABASE",MODE_PRIVATE,null);
          db.execSQL("Create table if not exists BloodDonor(name varchar,email varchar,mobile_no int,address varchar,blood_group varchar,password varchar)");
  
      }
  
      public void action(View v)
      {
  
      switch(v.getId()){
      case R.id.login:
          Intent i=new Intent(this,Login.class);
          startActivityForResult(i, 500);
          break;
  
      case R.id.sign_up:
          String name=tv1.getText().toString();
          String email=tv2.getText().toString();
          String mobile=tv3.getText().toString();
          String address=tv4.getText().toString();
          String bloodgroup=tv5.getText().toString();
          String password=tv6.getText().toString();
  
          if(name==null||name==""||name.length()&lt;3)
          {
              show("Please Enter Correct Name.");
          }
  
          else if(email==null||email==""||email.length()&lt;10)
          {
              show("Please Enter Correct Email id.");
          }
          else if(mobile==null||mobile==""||mobile.length()&lt;10)
          {
              show("Please Enter Correct mobile number.");
          }
          else if(address==null||address==""||address.length()&lt;5)
          {
              show("Please Enter Correct address.");
          }
          else if(bloodgroup==null||bloodgroup==""||bloodgroup=="A+ve"||bloodgroup=="A+VE"||bloodgroup=="B+VE"
                  ||bloodgroup=="B+ve"||bloodgroup=="AB+ve"||bloodgroup=="AB+VE"||bloodgroup=="O+ve"
                  ||bloodgroup=="O+VE"||bloodgroup=="A-ve"||bloodgroup=="A-VE"||bloodgroup=="B-VE"
                  ||bloodgroup=="B-ve"||bloodgroup=="AB-ve"||bloodgroup=="AB-VE"||bloodgroup=="O-ve"
                  ||bloodgroup=="O-VE")
          {
              show("Please Enter Correct blood group.");
          }
          else if(password==null||password==""||password.length()&lt;6)
          {
              show("Please Enter Strong Password.");
          }
          else
          {   
              db.execSQL("insert into login values('"+name+"','"+email+"','"+mobile+"','"+address+"','"+bloodgroup+"','"+password+"''nothing')");
              i=new Intent(this,Home.class);
              startActivityForResult(i, 500);
  
              db.close();
              finish();
          }
          break;
      }
  
  }   
  
  
  public void show(String str){
  
      Toast.makeText(this,str,Toast.LENGTH_LONG).show();
  
  }   
  
  
  
  }
  </code></pre>
  
  <p>here is my logcat </p>
  
  <p>07-03 07:05:55.780: D/dalvikvm(795): GC_FOR_ALLOC freed 69K, 7% free 2631K/2820K, paused 129ms, total 169ms</p>
  
  <p>07-03 07:05:55.819: I/dalvikvm-heap(795): Grow heap (frag case) to 4.147MB for 1536016-byte allocation</p>
  
  <p>07-03 07:05:56.039: D/dalvikvm(795): GC_FOR_ALLOC freed 2K, 5% free 4128K/4324K, paused 194ms, total 194ms</p>
  
  <p>07-03 07:05:58.410: D/gralloc_goldfish(795): Emulator without GPU emulation detected.</p>
  
  <p>07-03 07:06:12.809: D/dalvikvm(795): GC_FOR_ALLOC freed 15K, 4% free 4242K/4376K, paused 128ms, total 130ms</p>
  
  <p>07-03 07:06:12.859: I/dalvikvm-heap(795): Grow heap (frag case) to 5.720MB for 1536016-byte allocation</p>
  
  <p>07-03 07:06:13.109: D/dalvikvm(795): GC_FOR_ALLOC freed 1K, 3% free 5741K/5880K, paused 245ms, total 245ms</p>
  
  <p>07-03 07:06:16.108: I/Choreographer(795): Skipped 75 frames!  The application may be doing too much work on its main thread.</p>
  
  <p>07-03 07:06:22.759: I/Choreographer(795): Skipped 44 frames!  The application may be doing too much work on its main thread.</p>
  
  <p>07-03 07:06:54.290: I/Choreographer(795): Skipped 32 frames!  The application may be doing too much work on its main thread.</p>
  
  <p>07-03 07:07:03.780: D/AndroidRuntime(795): Shutting down VM</p>
  
  <p>07-03 07:07:03.789: W/dalvikvm(795): threadid=1: thread exiting with uncaught exception (group=0x414c4700)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795): FATAL EXCEPTION: main</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795): java.lang.IllegalStateException: Could not execute method of the activity</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.view.View$1.onClick(View.java:3633)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.view.View.performClick(View.java:4240)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.view.View$PerformClick.run(View.java:17721)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.os.Handler.handleCallback(Handler.java:730)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.os.Handler.dispatchMessage(Handler.java:92)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.os.Looper.loop(Looper.java:137)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.app.ActivityThread.main(ActivityThread.java:5103)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at java.lang.reflect.Method.invokeNative(Native Method)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at java.lang.reflect.Method.invoke(Method.java:525)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at dalvik.system.NativeStart.main(Native Method)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795): Caused by: java.lang.reflect.InvocationTargetException</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at java.lang.reflect.Method.invokeNative(Native Method)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at java.lang.reflect.Method.invoke(Method.java:525)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at android.view.View$1.onClick(View.java:3628)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  ... 11 more</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795): Caused by: java.lang.NullPointerException</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  at com.example.minorproject.SignUp.action(SignUp.java:47)</p>
  
  <p>07-03 07:07:03.869: E/AndroidRuntime(795):  ... 14 more</p>
  
  <p>07-03 07:07:10.749: D/dalvikvm(828): GC_FOR_ALLOC freed 73K, 7% free 2631K/2824K, paused 38ms, total 41ms</p>
  
  <p>07-03 07:07:10.759: I/dalvikvm-heap(828): Grow heap (frag case) to 4.147MB for 1536016-byte allocation</p>
  
  <p>07-03 07:07:10.879: D/dalvikvm(828): GC_FOR_ALLOC freed 2K, 5% free 4129K/4328K, paused 113ms, total 113ms</p>
  
  <p>07-03 07:07:11.489: I/Choreographer(828): Skipped 30 frames!  The application may be doing too much work on its main thread.</p>
  
  <p>07-03 07:07:11.519: D/gralloc_goldfish(828): Emulator without GPU emulation detected</p>