java.lang.RuntimeException: Unable to start activity and onclick automatically switch to other activity
<p>I was testing my code first time it work fine i change table name in database and after that it's one button is not working and another button open anther link ,how its possible when  i m giving link through intent to open certain file plz help me i m tried lot .i m attaching error log and code below </p>

<pre><code>`02-25 00:30:57.309: E/AndroidRuntime(9758): FATAL EXCEPTION: main`
02-25 00:30:57.309: E/AndroidRuntime(9758): java.lang.RuntimeException: Unable to   
start activity ComponentInfo{a.vaccination/a.vaccination.profilelist}:    
java.lang.NullPointerException
02-25 00:30:57.309: E/AndroidRuntime(9758):     at    
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at   
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at  
android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at  
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at   
android.os.Looper.loop(Looper.java:123)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at   
android.app.ActivityThread.main(ActivityThread.java:3729)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at  
java.lang.reflect.Method.invokeNative(Native Method)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
java.lang.reflect.Method.invoke(Method.java:507)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at   
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
dalvik.system.NativeStart.main(Native Method)
02-25 00:30:57.309: E/AndroidRuntime(9758): Caused by: java.lang.NullPointerException
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
a.vaccination.profilelist.onCreate(profilelist.java:21)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-25 00:30:57.309: E/AndroidRuntime(9758):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
02-25 00:30:57.309: E/AndroidRuntime(9758):     ... 11 more
02-25 00:34:19.239: E/AndroidRuntime(10023): FATAL EXCEPTION: main
02-25 00:34:19.239: E/AndroidRuntime(10023): java.lang.RuntimeException: Unable to 
start activity ComponentInfo{a.vaccination/a.vaccination.profilelist}:   
java.lang.NullPointerException
</code></pre>

<p>and code for MainActivity</p>

<pre><code>package a.vaccination;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button b1, b2, b3, b4;

    b1 = (Button) findViewById(R.id.button1);
    b2 = (Button) findViewById(R.id.button2);
    b3 = (Button) findViewById(R.id.button3);
    b4 = (Button) findViewById(R.id.button4);

    b1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // navigate to profiles child.xml

            Intent it = new Intent(MainActivity.this,   
profilelist.class);
            startActivity(it);

        }
    });

    b2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // navigate to vaccinations details

            Intent it2 = new Intent(MainActivity.this,  
vaccination.class);
            startActivity(it2);

        }
    });

    b3.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // exit
            finish();

        }
    });
    b4.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent it = new Intent(MainActivity.this,

com.androidhive.googleplacesandmaps.MainActivity.class);
            startActivity(it);

        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}
</code></pre>

<p>XML file </p>

<pre><code>    &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/needle"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".MainActivity" &gt;

&lt;Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="23dp"
    android:layout_marginLeft="22dp"
    android:text="Get Nearest Hospital"
    android:textColor="@android:color/background_dark" /&gt;

&lt;Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button1"
    android:layout_below="@+id/button1"
    android:layout_marginTop="30dp"
    android:text="Vaccines List"
    android:textColor="@android:color/background_dark" /&gt;

&lt;Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button2"
    android:layout_below="@+id/button2"
    android:layout_marginTop="44dp"
    android:text="Exit"
    android:textColor="@android:color/background_dark" /&gt;

&lt;Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button4"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="27dp"
    android:layout_marginTop="26dp"
    android:text="Profiles"
    android:textColor="@android:color/background_dark" /&gt;

&lt;/RelativeLayout&gt;


profilelist.java


package a.vaccination;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;


public class profilelist extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.child);

    Button add = (Button) findViewById(R.id.button1);

    add.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // navigate to create profile
            Intent it = new Intent(profilelist.this,   
createprofile.class);
            startActivity(it);

        }
    });


    ListView name=(ListView)findViewById(R.id.listView1);


}
}
</code></pre>

<p>child.XML</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/needle" &gt;

&lt;ListView
    android:id="@+id/listView1"
    android:layout_width="wrap_content"
    android:layout_height="101dp" &gt;
&lt;/ListView&gt;

&lt;RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" &gt;

    &lt;Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="98dp"
        android:layout_marginTop="48dp"
        android:text="Add Baby" /&gt;
&lt;/RelativeLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>
