title: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String)' on a null object reference
body: <p>I am trying to run an App with SQLite, but whenever I click on a button to enter some data this message appear </p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method 'int
    android.os.Bundle.getInt(java.lang.String)' on a null object reference
      at com.example.carlos.assigmentcarlos.Register$1.onClick(Register.java:39)</p>
  </blockquote>
  
  <p>This is part of my code</p>
  
  <pre><code>package com.example.carlos.assigmentcarlos;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  
  public class MainActivity extends ActionBarActivity {
      Button Login, Register, Delete, Update;
      int status = 0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Login = (Button) findViewById(R.id.Login);
          Register = (Button) findViewById(R.id.Reg);
          Delete = (Button) findViewById(R.id.Delete);
          Update = (Button) findViewById(R.id.Update);
          Login.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  status = 1;
                  Bundle b = new Bundle();
                  b.putInt("status", status);
  
                  Intent i = new Intent(MainActivity.this, Register.class);
                  i.putExtras(b);
                  startActivity(i);
  
              }
          });
  
          Register.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent i = new Intent(MainActivity.this, Register.class);
                  startActivity(i);
              }
          });
          Update.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  status = 2;
                  Bundle b = new Bundle();
                  b.putInt("status", status);
                  Intent i = new Intent(MainActivity.this, Register.class);
                  i.putExtras(b);
                  startActivity(i);
              }
          });
          Delete.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  status = 3;
                  Bundle b = new Bundle();
                  b.putInt("status", status);
                  Intent i = new Intent(MainActivity.this, Register.class);
                  i.putExtras(b);
                  startActivity(i);
  
              }
          });
      }
  }
  </code></pre>
  
  <p>Register class</p>
  
  <pre><code>package com.example.carlos.assigmentcarlos;
  
  /**
   * Created by Carlos on 22/04/2016.
   */
  
  
      import android.app.Activity;
      import android.content.Context;
      import android.content.Intent;
      import android.database.Cursor;
      import android.os.Bundle;
      import android.view.View;
      import android.view.View.OnClickListener;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.Toast;
  
      public class Register extends Activity {
          Button Login;
          EditText USERNAME,USERPASS;
          String username,userpass;
          Context CTX = this;
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              // TODO Auto-generated method stub
              super.onCreate(savedInstanceState);
              setContentView(R.layout.login_layout);
              Login = (Button) findViewById(R.id.b_login);
              USERNAME = (EditText) findViewById(R.id.user_name);
              USERPASS = (EditText) findViewById(R.id.user_pass);
              Login.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View arg0) {
  
  
                      Bundle b = getIntent().getExtras();
                      int status = b.getInt("status");
                      if(status == 1)
                      {
                          Toast.makeText(getBaseContext(), "Please wait...", Toast.LENGTH_LONG).show();
                          username = USERNAME.getText().toString();
                          userpass = USERPASS.getText().toString();
                          DatabaseOperations DOP = new DatabaseOperations(CTX);
                          Cursor CR = DOP.getInformation(DOP);
                          CR.moveToFirst();
                          boolean loginstatus = false;
                          String NAME = "";
                          do
                          {
                              if(username.equals(CR.getString(0))&amp;&amp; (userpass.equals(CR.getString(1))))
                              {
                                  loginstatus = true;
                                  NAME = CR.getString(0);
                              }
  
                          }while(CR.moveToNext());
                          if(loginstatus)
                          {
                              Toast.makeText(getBaseContext(), "Login Success----\n Welcome "+NAME, Toast.LENGTH_LONG).show();
                              finish();
                          }
                          else
                          {
                              Toast.makeText(getBaseContext(), "Login Failed---- ", Toast.LENGTH_LONG).show();
                              finish();
                          }
  
  
  
                      }
                      else if(status == 2)
                      {
                          Toast.makeText(getBaseContext(), "Please wait...", Toast.LENGTH_LONG).show();
                          username = USERNAME.getText().toString();
                          userpass = USERPASS.getText().toString();
                          DatabaseOperations DOP = new DatabaseOperations(CTX);
                          Cursor CR = DOP.getInformation(DOP);
                          CR.moveToFirst();
                          boolean loginstatus = false;
                          String NAME = "";
                          do
                          {
                              if(username.equals(CR.getString(0))&amp;&amp; (userpass.equals(CR.getString(1))))
                              {
                                  loginstatus = true;
                                  NAME = CR.getString(0);
                              }
  
                          }while(CR.moveToNext());
                          if(loginstatus)
                          {
                              Toast.makeText(getBaseContext(), "Login Success----\n Welcome "+NAME, Toast.LENGTH_LONG).show();
  
                              Intent i = new Intent("update_filter");
                              Bundle BN = new Bundle();
                              BN.putString("user_name",NAME );
                              BN.putString("user_pass",userpass );
                              i.putExtras(BN);
                              startActivity(i);
                              finish();
                          }
                          else
                          {
                              Toast.makeText(getBaseContext(), "Login Failed---- ", Toast.LENGTH_LONG).show();
                              finish();
                          }
  
  
  
  
  
  
                      }
                      else if(status == 3)
                      {
                          Toast.makeText(getBaseContext(), "Please wait...", Toast.LENGTH_LONG).show();
                          username = USERNAME.getText().toString();
                          userpass = USERPASS.getText().toString();
                          DatabaseOperations DOP = new DatabaseOperations(CTX);
                          Cursor CR = DOP.getInformation(DOP);
                          CR.moveToFirst();
                          boolean loginstatus = false;
                          String NAME = "";
                          do
                          {
                              if(username.equals(CR.getString(0))&amp;&amp; (userpass.equals(CR.getString(1))))
                              {
                                  loginstatus = true;
                                  NAME = CR.getString(0);
                              }
  
                          }while(CR.moveToNext());
                          if(loginstatus)
                          {
                              Toast.makeText(getBaseContext(), "Login Success----\n Welcome "+NAME, Toast.LENGTH_LONG).show();
                              Intent i = new Intent("delete_filter");
                              Bundle B = new Bundle();
                              B.putString("user_name",NAME );
                              i.putExtras(B);
                              startActivity(i);
  
                              finish();
                          }
                          else
                          {
                              Toast.makeText(getBaseContext(), "Login Failed---- ", Toast.LENGTH_LONG).show();
                              finish();
                          }
  
  
  
  
                          Intent i = new Intent("delete_filter");
                          startActivity(i);
                      }
  
                  }
              });
          }
  
      }
  </code></pre>
  
  <p>Database Operations</p>
  
  <pre><code>package com.example.carlos.assigmentcarlos;
  
  /**
   * Created by Carlos on 22/04/2016.
   */
  
  
  import com.example.carlos.assigmentcarlos.tableData.TableInfo;
      import android.content.ContentValues;
      import android.content.Context;
      import android.database.Cursor;
      import android.database.sqlite.SQLiteDatabase;
      import android.database.sqlite.SQLiteDatabase.CursorFactory;
      import android.database.sqlite.SQLiteOpenHelper;
      import android.provider.SyncStateContract.Columns;
      import android.util.Log;
  
      public class DatabaseOperations extends SQLiteOpenHelper {
          public static final int database_version = 1;
          public String CREATE_QUERY = "CREATE TABLE "+TableInfo.TABLE_NAME+"("+TableInfo.USER_NAME+" TEXT,"+TableInfo.USER_PASS+" TEXT);";
  
          public DatabaseOperations(Context context) {
              super(context, TableInfo.DATABASE_NAME, null, database_version);
              Log.d("Database operations", "Database created");
  
          }
  
          @Override
          public void onCreate(SQLiteDatabase sdb) {
  
              sdb.execSQL(CREATE_QUERY);
              Log.d("Database operations", "Table created");
  
          }
  
          @Override
          public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
              // TODO Auto-generated method stub
  
          }
  
          public void putInformation(DatabaseOperations dop,String name,String pass)
  
          {
              SQLiteDatabase SQ = dop.getWritableDatabase();
              ContentValues cv = new ContentValues();
              cv.put(TableInfo.USER_NAME, name);
              cv.put(TableInfo.USER_PASS, pass);
              long k = SQ.insert(TableInfo.TABLE_NAME, null, cv);
              Log.d("Database operations", "One raw inserted");
  
  
  
          }
  
          public Cursor getInformation(DatabaseOperations dop)
          {
              SQLiteDatabase SQ = dop.getReadableDatabase();
              String[] coloumns = {TableInfo.USER_NAME,TableInfo.USER_PASS};
              Cursor CR = SQ.query(TableInfo.TABLE_NAME,coloumns, null, null, null, null, null);
              return CR;
  
  
          }
  
          public Cursor getUserPass(DatabaseOperations DOP, String user)
          {
              SQLiteDatabase SQ = DOP.getReadableDatabase();
              String selection = TableInfo.USER_NAME +" LIKE ?";
              String coloumns[] = {TableInfo.USER_PASS};
              String args[] = {user};
              Cursor CR = SQ.query(TableInfo.TABLE_NAME, coloumns, selection, args, null, null, null);
              return CR;
  
          }
  
          public void deleteUser(DatabaseOperations DOP, String user, String pass)
          {
              String selection = TableInfo.USER_NAME+ " LIKE ? AND "+TableInfo.USER_PASS +" LIKE ?";
              //String coloumns[] = {TableInfo.USER_PASS};
              String args[] = {user,pass};
              SQLiteDatabase SQ = DOP.getWritableDatabase();
              SQ.delete(TableInfo.TABLE_NAME, selection, args);
  
          }
  
          public void updateUserInfo(DatabaseOperations DOP, String user_name, String user_pass, String new_user_name )
          {
              SQLiteDatabase SQ  = DOP.getWritableDatabase();
              String selection = TableInfo.USER_NAME+ " LIKE ? AND "+TableInfo.USER_PASS +" LIKE ?";
              String args[] = {user_name,user_pass};
              ContentValues values = new ContentValues();
              values.put(TableInfo.USER_NAME, new_user_name);
              SQ.update(TableInfo.TABLE_NAME, values, selection, args);
  
  
          }
  
  
      }
  </code></pre>