Advertisement
Guest User

Untitled

a guest
Mar 11th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. 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
  2.  
  3. Here is my function to get data from Db:
  4. <pre><code>
  5. public Cursor getInformation(DatabaseHandler db){
  6. SQLiteDatabase sq = db.getWritableDatabase();
  7. String[] columnNames ={"StudentName","StudentEmail","StudentPassword",
  8. "StudentConfirmPassword","InstituteName","ContactInfo"};
  9. String tableName = "StudentRecords";
  10. Cursor cr = sq.query(tableName,columnNames,null,null,null,null,null);
  11. return cr;
  12. }
  13.  
  14. </code></pre>
  15.  
  16. Part of code where I am trying to call this function :
  17. <pre><code>
  18.  
  19.  
  20. > btn = (Button) findViewById(R.id.loginButton);
  21. > userName = (EditText) findViewById(R.id.userName);
  22. > passWord = (EditText) findViewById(R.id.passWord);
  23. > btn.setOnClickListener(new View.OnClickListener() {
  24. > @Override
  25. > public void onClick(View view) {
  26. > String username = userName.getText().toString();
  27. > String userpass = passWord.getText().toString();
  28. > boolean login_status = false;
  29. > Cursor cr1 = dbHandler.getInformation(dbHandler);
  30. > String name = "";
  31. > cr1.moveToFirst();
  32. > do {
  33. > if(username.equals(cr1.getString(0))
  34. > &&userpass.equals(cr1.getString(2))){
  35. > login_status = true;
  36. > name = cr1.getString(0);
  37. > }
  38. > }while(cr1.moveToNext());
  39. > if (login_status){
  40. > Intent intentMain = new Intent(welcomepage.this,
  41. > UserProfile.class);
  42. > startActivity(intentMain);
  43. > finish();
  44. > } }while(cr1.moveToNext());
  45. > if (login_status){
  46. > Intent intentMain = new Intent(welcomepage.this,
  47. > UserProfile.class);
  48. > startActivity(intentMain);
  49. > finish();
  50. > }
  51.  
  52. </code></pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement