My app keeps crashing when i go to other activity : I am trying to make an app named 'moviesinfo', in which i have a login page, with sign up and forgot password option. When i try to login,the app crashes. I also don't know if the data entered on the sign up page is being stored in the database or not. 

This is my mainactivity.java

```
package com.example.moviesinfo;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    SQLiteDatabase db;
    SQLiteOpenHelper openHelper;
    private EditText user;
    private EditText password;
    private Button btn;
    private Button btn2;
    private Button forgot;
    Cursor cursor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        forgot=findViewById(R.id.forgot);
        btn2=(Button) findViewById(R.id.signup);
        user= (EditText) findViewById(R.id.username);
        password = (EditText) findViewById(R.id.password);
        btn = (Button) findViewById(R.id.login);
        openHelper= new DatabaseHelper(this);
        db=openHelper.getReadableDatabase();

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String username1= user.getText().toString();
                String password1= password.getText().toString();

                cursor = db.rawQuery("SELECT * FROM " +DatabaseHelper.TABLENAME + " WHERE " + DatabaseHelper.COL2 + "=? AND " + DatabaseHelper.COL3+"=?", new String[]{username1,password1});

                if (cursor!=null){
                    if (cursor.getCount()>0){
                        cursor.moveToNext();
                        Intent intent = new Intent(MainActivity.this,listmenu.class);
                        startActivity(intent);
                        //Toast.makeText(getApplicationContext(),"Login Successful", Toast.LENGTH_SHORT).show();//
                    }else{
                        Toast.makeText(getApplicationContext(),"Error" , Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });


        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sign_up();
            }
        });

        forgot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                forgot();
            }
        });
    }


    private void sign_up()
    {
        Intent intent= new Intent(MainActivity.this, signup.class);
        startActivity(intent);
    }

    private void forgot()
    {
        Intent intent= new Intent(MainActivity.this, forgot.class);
        startActivity(intent);
    }
}
```

This is the signup.java class

```
package com.example.moviesinfo;

import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.lang.String;
import java.util.ArrayList;

public class signup extends AppCompatActivity {
    SQLiteOpenHelper openHelper;
    DatabaseHelper db;
    SQLiteDatabase db1;
    public String uname = "";
    public String pwd = "";
    public ArrayList<String> cpwd = new ArrayList<String>();

    EditText e1, e2, e3;
    Button b1,b2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup);
        openHelper= new DatabaseHelper(this);
        e1 = (EditText) findViewById(R.id.username);
        e2 = (EditText) findViewById(R.id.password);
        e3 = (EditText) findViewById(R.id.cpwd);
        b1 = (Button) findViewById(R.id.save);
        b2 = (Button) findViewById(R.id.login2);


        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            db1=openHelper.getWritableDatabase();
            String username =e1.getText().toString();
                String password =e2.getText().toString();
                String confirm_password =e3.getText().toString();
                insert_data(username,password,confirm_password);
            }
        });

        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(signup.this,MainActivity.class);
                startActivity(intent);
            }
        });


    }

    public void insert_data(String username, String password, String confirm_password)
    {
        ContentValues contentValues = new ContentValues();
        contentValues.put(DatabaseHelper.COL2, username);
        contentValues.put(DatabaseHelper.COL3, password);
        contentValues.put(DatabaseHelper.COL4, confirm_password);
        long id=db1.insert(DatabaseHelper.TABLENAME, null, contentValues);
    }
}
```

This is the DatabseHelper.java class

```
package com.example.moviesinfo;

import com.example.moviesinfo.signup;

import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME="userdetails.db";
    public static final String TABLENAME="user details";
    public static final String COL1="id";
    public static final String COL2="username";
    public static final String COL3="password";
    public static final String COL4="confirmpassword";



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

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + "TABLENAME(ID INTEGER PRIMARY KEY AUTOINCREMENT,USERNAME TEXT,PASSWORD TEXT,CONFIRMPASSWORD TEXT)");

    }

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

}
```





I expect that when i click the login button it should jump to next activity with checking the login details from the database.