Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- E/AndroidRuntime: FATAL EXCEPTION: main Process: com.edkul.vimal.edkul, PID: 2006 java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.Cursor com.edkul.vimal.edkul.DatabaseHandler.getInformation(com.edkul.vimal.edkul.DatabaseHandler)' on a null object reference
- Here is my function to get data from Db:
- <pre><code>
- public Cursor getInformation(DatabaseHandler db){
- SQLiteDatabase sq = db.getWritableDatabase();
- String[] columnNames ={"StudentName","StudentEmail","StudentPassword",
- "StudentConfirmPassword","InstituteName","ContactInfo"};
- String tableName = "StudentRecords";
- Cursor cr = sq.query(tableName,columnNames,null,null,null,null,null);
- return cr;
- }
- </code></pre>
- Part of code where I am trying to call this function :
- <pre><code>
- > btn = (Button) findViewById(R.id.loginButton);
- > userName = (EditText) findViewById(R.id.userName);
- > passWord = (EditText) findViewById(R.id.passWord);
- > btn.setOnClickListener(new View.OnClickListener() {
- > @Override
- > public void onClick(View view) {
- > String username = userName.getText().toString();
- > String userpass = passWord.getText().toString();
- > boolean login_status = false;
- > Cursor cr1 = dbHandler.getInformation(dbHandler);
- > String name = "";
- > cr1.moveToFirst();
- > do {
- > if(username.equals(cr1.getString(0))
- > &&userpass.equals(cr1.getString(2))){
- > login_status = true;
- > name = cr1.getString(0);
- > }
- > }while(cr1.moveToNext());
- > if (login_status){
- > Intent intentMain = new Intent(welcomepage.this,
- > UserProfile.class);
- > startActivity(intentMain);
- > finish();
- > } }while(cr1.moveToNext());
- > if (login_status){
- > Intent intentMain = new Intent(welcomepage.this,
- > UserProfile.class);
- > startActivity(intentMain);
- > finish();
- > }
- </code></pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement