title: How to access a sql database from a widget application
body: <p>Because of some comments, the question in a nutshell:</p>
  
  <p>How can a widget access its own sqlite database? </p>
  
  <p>Why does it not work with a plain DatabaseAdapter class?</p>
  
  <p>Are certain permissions required? </p>
  
  <p>Are there limitations imposed upon a Remotevie/AppWidgetProvider to access its own database (without a ContentProvider)</p>
  
  <hr>
  
  <h2>The question seems simple, but details follow, if someone really wants to know why I am asking:</h2>
  
  <p>I have the following setup:</p>
  
  <ol>
  <li><p>I have a normal android application, which comes with quite a lot of HTML pages in the assets folder. Because of the size of the app, the prefered install location is the external sd card. This works fine.</p></li>
  <li><p>That means that the app cannot contain a widget, because he widget needs to reside in the internal ROM.</p></li>
  <li><p>Instead, the widget will read from the app's database on the external sd card. This is achieved through a ContentProvider/ContentProviderClient.</p></li>
  </ol>
  
  <p>So far that works fine.</p>
  
  <p>Now, that widget needs to maintain some persistent configuration settings, on a per instance basis. Therefore, the AppWidgetProvider class cannot use the preferences, because they would apply on a per class basis.</p>
  
  <p>So, to keep the (quite complex) instance-sepcific configuration data, I want the AppWidgetProvider class to have its own small sqllite database.</p>
  
  <p>Now, while I can access the app's database from the widget via the contentprovider, it seems that the widget cannot access its own database. I have a database adapter class in the widget project; inside the AppWidgetProvider, I have the Context, but no writing seems to happen.</p>
  
  <p>The calls to the database adapter get through OK (I've done some logging), but when I examine the tables, no writing has occurred.</p>
  
  <p>Why is that? Do I really need a ContentProvider inside the widget to access the widget's database? I do not want to go down that road, because when I implemnented the access to the apps database from the widget, I had to go through the ContentProviderClient instead of the ContentProvider. That would be very cumbersome. As I need a bit more than CRUD acccess, that obviously would involve creating a custom ContentProviderClient. The android docs clearly state that "You don't need a provider to use an SQLite database if the use is entirely within your own application." So IMHO, that would mean, that the widget can access its on database directly? Do I need special permissions? I suspect that, because the widgets run as RemoteViews in the homescreen process, access to the db is somehow limited?
  Any thoughts, ideas, hints on this?</p>