1

In my application I write jobs into a queue in a SQLite table. With a JobService I would like to process this queue.

I'm currently struggling to access the database from inside the the JobService as I require the Context. Both getBaseContext() and getApplicationContext() leave me with

Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference

As I seem to gather from https://developer.android.com/reference/android/app/job/JobService.html JobService seems to inherit from Context but it doesn't seem sufficient to just use this as Context.

I'm using a helper class extending SQLiteOpenHelper with the database.

Thank you for your time.

€: I was too hasty and tried to use this as context in my constructor. As soon as I moved my initialization code to a different part it works as intended.

celphy
  • 127
  • 11
  • 1
    Please provide a [mcve]. This would include the complete Java stack trace, plus your code that is referenced in that stack trace. – CommonsWare Dec 13 '17 at 14:21
  • Thanks for taking the time. It was a stupid mistake and I edited the solution into my question. – celphy Dec 13 '17 at 14:38

0 Answers0