Error Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
<p>I have been trying to create a module in the app. This module is like create a new user profile. When user taps on the icon in the toolbar it shows the dialog box which has the form. </p>

<p>The form has 5 main input</p>

<ol>
<li>Name --> Used EditText</li>
<li>Gender --> Used RadioGroup</li>
<li>Height --> Used EditText</li>
<li>Weight --> Used EditText</li>
<li>Age --> Used EditText</li>
</ol>

<p>When I click on the dialog box <strong>done</strong> button it should save the information in the SQLite database and create a <strong>usercard</strong> in the phone at the sametime. User can create N number of profile in the app and for that user has to fill the info and tap on the done but whenever user taps on the done button it crashes the whole app. This much I have gone so far and encountered a problem - </p>

<p><strong>add_form.xml</strong></p>

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

    &lt;TextView
        android:id="@+id/form_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#3498DB"
        android:textColor="#FFF"
        android:textSize="21sp"
        android:padding="16dp"
        android:text="ADD PERSON"/&gt;
    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:layout_below="@+id/form_title"&gt;
        &lt;EditText
            android:id="@+id/person_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="16dp"
            android:paddingBottom="16dp"
            android:textSize="14sp"
            android:hint="PERSON NAME"
            android:inputType="text" /&gt;

        &lt;RadioGroup
            android:id="@+id/gender_selection"
            android:layout_below="@+id/person_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:orientation="horizontal"&gt;
            &lt;RadioButton
                android:id="@+id/male"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="MALE"
                android:onClick="RadioButtonClicked"
                /&gt;
            &lt;RadioButton
                android:id="@+id/female"
                android:layout_marginLeft="16dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="FEMALE"
                android:onClick="RadioButtonClicked"/&gt;
        &lt;/RadioGroup&gt;

        &lt;LinearLayout
            android:id="@+id/person_metrics"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:layout_below="@+id/gender_selection"&gt;
            &lt;LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_weight="1"&gt;
                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="WEIGHT"/&gt;
                &lt;EditText
                    android:id="@+id/person_weight"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:padding="16dp"
                    android:textSize="21sp"
                    android:hint="KG"
                    android:inputType="text" /&gt;
            &lt;/LinearLayout&gt;
            &lt;LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_weight="1"&gt;
                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="HEIGHT"/&gt;
                &lt;EditText
                    android:id="@+id/person_height"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:padding="16dp"
                    android:textSize="21sp"
                    android:hint="M"
                    android:inputType="text" /&gt;
            &lt;/LinearLayout&gt;
            &lt;LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_weight="1"&gt;
                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="AGE"/&gt;
                &lt;EditText
                    android:id="@+id/person_age"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:padding="16dp"
                    android:textSize="21sp"
                    android:hint="Y"
                    android:inputType="text" /&gt;
            &lt;/LinearLayout&gt;

        &lt;/LinearLayout&gt;
    &lt;/RelativeLayout&gt;

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

<p><strong>PersonDBHelper.java</strong></p>

<pre><code>package com.example.kuro.bloodpressure;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.Editable;

/**
 * Created by Kuro on 4/18/2016.
 */
public class PersonDBHelper extends SQLiteOpenHelper{

    public static final String DATABASE_NAME = "person_profile.db";
    public static final String TABLE_NAME = "person_info_table";
    public static final String id = "ID";
    public static final String name = "NAME";
    public static final String gender = "GENDER";
    public static final String weight = "WEIGHT";
    public static final String height = "HEIGHT";
    public static final String age = "AGE";
//    public static final String blood_pressure_upper = "BPU";
//    public static final String blood_pressure_lowser = "BPL";
//    public static final String heart_beat = "HB";

    public PersonDBHelper(Context context) {
        super(context, DATABASE_NAME,null,1);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table " + TABLE_NAME +
                "(ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
                " NAME STRING, " +
                " GENDER STRING," +
                " WEIGHT INTEGER," +
                " HEIGHT INTEGER, " +
                " AGE INTEGER)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXSITS"+TABLE_NAME);
        onCreate(db);
    }

    public boolean insertData(String name, String gender, String weight, String height, String age){
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();

        contentValues.put(name,name);
        contentValues.put(gender,gender);
        contentValues.put(weight,weight);
        contentValues.put(height,height);
        contentValues.put(age, age);

        long result = db.insert(TABLE_NAME,null,contentValues);
        if (result==-1) return false;
        else return true;
    }

    public Cursor getAllData(){
        SQLiteDatabase db = this.getWritableDatabase();
        Cursor res = db.rawQuery("select * from"+TABLE_NAME,null);
        return res;
    }
}
</code></pre>

<p><strong>MainActivity.java</strong></p>

<pre><code>package com.example.kuro.bloodpressure;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.app.Fragment;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {
    public Toolbar mtoolbar;
    public TabLayout mtabLayout;
    public ViewPager mviewPager;
    public ViewPagerAdapter viewPagerAdapter;
    PersonDBHelper mydb;

    EditText name, weight, height, age;
    RadioGroup mradioGroup;
    RadioButton male,female;
    TextView selectedGender;
    private String gender_value;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mtoolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mtoolbar);

        mtabLayout = (TabLayout) findViewById(R.id.tablayout);
        mviewPager = (ViewPager) findViewById(R.id.viewpager);
        viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
        viewPagerAdapter.addFragments(new Measure(), "MEASURE");
        viewPagerAdapter.addFragments(new People(), "PEOPLE");
        mviewPager.setAdapter(viewPagerAdapter);
        mtabLayout.setupWithViewPager(mviewPager);

        mydb = new PersonDBHelper(this);


    }

    public void RadioButtonClicked(View view) {
        boolean checked = ((RadioButton) view).isChecked();
        switch (view.getId()) {
            case R.id.male:
                if (checked)gender_value = "male";
                else male.setChecked(false);
                break;
            case R.id.female:
                if (checked) gender_value = "female";
                else female.setChecked(false);
                break;
        }

    }


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

    public void viewAll(){

    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.add_person:
                AlertDialog.Builder add_people_form = new AlertDialog.Builder(MainActivity.this);
                add_people_form.setView(R.layout.add_form)
                        .setCancelable(false)
                        .setPositiveButton("DONE", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {


                                name = (EditText) findViewById(R.id.person_name);
                                mradioGroup = (RadioGroup)findViewById(R.id.gender_selection);
                                male = (RadioButton)findViewById(R.id.male);
                                female = (RadioButton)findViewById(R.id.female);
                                weight = (EditText) findViewById(R.id.person_weight);
                                height = (EditText) findViewById(R.id.person_height);
                                age = (EditText) findViewById(R.id.person_age);


                                String user_name = (String) name.getText().toString();
                                String user_gender = (String) gender_value;
                                String user_weight = (String) weight.getText().toString();
                                String user_height = (String) height.getText().toString();
                                String user_age = (String) age.getText().toString();

                                boolean isInserted = mydb.insertData(user_name,user_gender,user_weight,user_height,user_age);
                                if(isInserted==true)
                                    Toast.makeText(MainActivity.this,"ADDED",Toast.LENGTH_LONG).show();
                                else
                                    Toast.makeText(MainActivity.this,"NOT ADDED",Toast.LENGTH_LONG).show();
                            }
                        })
                        .setNegativeButton("CANCLE", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        });
                AlertDialog alert = add_people_form.create();
                alert.show();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

}
</code></pre>

<p><strong>Logcat</strong></p>

<pre><code>04-18 23:22:44.207 28079-28079/com.example.kuro.bloodpressure E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.example.kuro.bloodpressure, PID: 28079
                                                                            java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
                                                                                at com.example.kuro.bloodpressure.MainActivity$2.onClick(MainActivity.java:111)
                                                                                at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:162)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5343)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
</code></pre>