Reputation: 11053
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?
Upvotes: 0
Views: 81
Reputation: 52936
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.
Upvotes: 1