I have application that uses direct data access to it’s Database. I have nothing to expose outside of it for other applications. As CommonsWare says somewhere on SO, “if you have nothing to expose – don’t use ContentProvider”. Now, I want to add widget to display a couple of strings from one of the tables, storing in Database. Should I refactor the direct access code to the ContentProvider pattern? Is there a way to use direct access to Database from widget? Is there a way to have both ContentProvider and direct access to database in one application?
Share
I am going to assume that by “widget” you really mean “app widget”.
You do not have to do this just because you are writing an app widget.
Sure, using the same mechanisms you are using anywhere else in your app.
Yes, though you have to be a bit careful to make sure that you are using the same
SQLiteDatabaseobject in both cases, so you do not run into threading issues.