How to access the sqlite databases inside the widget class. The widget class which extends the appwidgetprovider does not have an activity hence i am not able to access the databases inside it.
1 Answer
There are 2 approaches for such a problem :
1) you say you don't have an activity inside a widget provider but actually the appwidget will execute inside the application context of your app declaring the widget. When you override
onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
you receive a context that could be used to get access to a database.
2) however, it would be more androidy to declare a service that would perform the query to the database, manage exceptions, retries, and so on and would provide its data either through a call back to an intent to update your widget, or, better, through a content provider that your widget could address.
Regards, Stéphane