• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException when using database object

 
Julius Almeuda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to Android, and i've got some issues. It looks like it's saying that's having an null object passed to it, but I'm not sure. Where I missed a step? Any help is appreciated.

Thanks in advance.

Logcat:


EmployeeOperations:



MainActivity:


 
Ron McLeod
Saloon Keeper
Posts: 1296
149
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In line 138 you create a new instance of EmployeeOperations, but never call its open() method (which presumably calls DatabaseHelper#getWritableDatabase()), so the instance's reference to the database does not get initialized, and is null when it is used in the next line.

 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!