database error when widget updates

I have a DB in my app which normally works perfectly. Now, I have added a widget with an update function which also accesses the DB. Once in a while, I get this error but only from within the widget update method.

Caused by:java.lang.NullPointerException
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)

Is there some kind of restriction on accessing a DB from within widget update method?

Answers


You shouldn't do any disk IO from the widget's BroadCast receiver (onUpdate()). Start a service that fetches the data and does the actual update. You might want to use an IntentServcie since it starts a worker thread by default.


Need Your Help

DIV: full height + scroll

html css

I want to have a DIV with:

Save a binary file in SQL Server as BLOB and text (or get the text from Full-Text index)

c# asp.net sql-server search-engine full-text-indexing

Currently we are saving files (PDF, DOC) into the database as BLOB fields. I would like to be able to retrieve the raw text of the file to be able to manipulate it for hit-highlighting and other