Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:36:36+00:00 2026-06-09T04:36:36+00:00

I have to force close when running my application with a null pointer exception.

  • 0

I have to force close when running my application with a null pointer exception. I think
I can not manage the database in the correct form.

package sarah.android;

import android.R.integer;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
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 SelesMeter2Activity extends Activity implements OnClickListener {
    EditText ed1;
    EditText ed2;
    Button b1;
    Button b2;
    Intent in;
    signup obj=new signup();

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ed1=(EditText) findViewById(R.id.ed1);
        ed2=(EditText) findViewById(R.id.ed2);
        b1= (Button) findViewById(R.id.bt1);
        b2= (Button) findViewById(R.id.bt2);
        b1.setOnClickListener(this);
        b2.setOnClickListener(this);
    }

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        //log in
        if (arg0.getId() == R.id.bt1)
        {
            String name=ed1.getText().toString();
            int pass = Integer.parseInt(ed2.getText().toString());
            if (obj.c.getString(0) == name&&obj.c.getInt(1) == pass)
            {
                in = new Intent(this,secondview.class);
                startActivity(in);
            }
            else
            {
                Toast.makeText(this, "please sing up first", 1000).show();
            }
        }
        else
            if (arg0.getId()==R.id.bt2)
            {
                in=new Intent(this,signup.class);
                startActivity(in);
            }
    }
}

The second activity which used to sign up the new users and put their information in my database:

package sarah.android;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.Toast;

public class signup extends Activity {
    SQLiteDatabase sql;
    Cursor c;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.singupx);
        Intent in = getIntent();
        Bundle b = in.getExtras();
        String n = b.getString("x");
        int p = Integer.valueOf(b.getString("y"));

        sql = openOrCreateDatabase("db",0, null);
        sql.execSQL("CREATE TABLE if not exists employee " +
                    " (name text NOT NULL UNIQUE" +
                    ",password integer NOT NULL UNIQUE)");
        sql.execSQL("insert into employee(name) values(" +
                    "'"+n+"') ");
        Toast.makeText(this,"Data inserted", 1000).show();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:36:38+00:00Added an answer on June 9, 2026 at 4:36 am

    It’s… quite simple. In your first activity, you didn’t put "x" or "y" into the intent. And in the second activity, you tried to get them.

    ...
    Bundle b=in.getExtras(); // perhaps this is null
    String n=b.getString("x"); // or this one
    int p=Integer.valueOf(b.getString("y")); // or this one
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stupid WinCE application where I'm just trying to force an exception
I have a weird error, I am not able to find a force close
I have an application I would like to force SSL on the login page
I have an android programm which manage a database. It this database, I write
I have this application (Windows form application written in Visual C++) from a colleague
I have an application which uses a SQL database. This is encapsulated by a
Lets say in an application you have an entity called User. Each User can
How to quit the app or force close the app when multiple activity running
I am not very experienced with VB.NET but I have to build an application
My application is running on the emulator no problem, but it does not work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.