Boardy
Boardy

Reputation: 36217

Android SQLite Database IO Error

I have a strange problem when accessing android sqlite datbase. I have a line of code that opens supposed to open the database file but it displays a null pointer exception as an IOException.

SQLiteDatabase myDB = this.openOrCreateDatabase("PasswordManager", MODE_PRIVATE, null);

This isn't in an activity class this is just in a standard java class. I know the datbase exists as I am using the same line in other parts of the code, the only difference, everywhere else is inside a class that extends an activity.

Thanks for any help you can offer.

Upvotes: 0

Views: 279

Answers (1)

Haphazard
Haphazard

Reputation: 10948

Pass a Context reference from the calling Activity to that Java class and use it to connect to your database.

Upvotes: 2

Related Questions