Answer the question
In order to leave comments, you need to log in
How to get Cursor in onCreate of Service?
Good afternoon.
Please tell me the best way to implement CURSOR creation in Android service.
I have ContentProvide, DataAdapter. In activation, when the application starts, my list is created. insert, update, query etc. methods work. when the database changes, the list is updated.
I also created Receiver and Service. reciver successfully catches system Broadcast messages and kicks the service. But no Cursor is created when the service starts, an exception occurs in dbHelper.getWritableDatabase() (I need to create a cursor in the onCreate method and next time the service is called in onStartCommand go to the next line, and so on every time the service is called.)
Error:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase com.***.mContentProvider$DatabaseHelper.getWritableDatabase()' on a null object reference
where *** is the application name.
Already broke my head with this problem.
What is the best way to fulfill this need?
Thank you!
Answer the question
In order to leave comments, you need to log in
Well, learn to read stack traces!
You haven't created a DatabaseHelper, you need to create one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question