title: Android App Widget with SQlite query
body: <p>I'm working on an App Widget which is being updated by a service, started from the onUpdate() section of the AppWidgetProvider class. The problem is that whenever I use Cursors inside the widget service, the views are not being added to the widget. If I simply replace the sql query/result for a string, it works.</p>
  
  <p>Not working example (using ContentProvider/SQL):</p>
  
  <pre><code>    public class TestWidgetService extends Service {
  
      @Override
      public void onStart(Intent intent, int startId) {
  
          AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
  
          ComponentName thisWidget = new ComponentName(getApplicationContext(), TestWidget.class);
  
          int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
  
          for (int widgetId : allWidgetIds) {
  
              RemoteViews remoteViews = new RemoteViews(
                      getApplicationContext().getPackageName(),
                      R.layout.test_widget
                      );
  
              // get items
  
              Uri items = Uri.parse(TestWidgetContent.CONTENT_URI + "/news/1");
              Cursor iCursor = getContentResolver().query(items, null, null, null, "ITM_TIMESTAMP DESC");
              if (iCursor == null) {
                  continue;
              }
              else if (iCursor.moveToFirst()) {
                  while (iCursor.isAfterLast() == false) {
  
                      Log.w("got", iCursor.getString(iCursor.getColumnIndex("FED_TITLE")));
  
                      RemoteViews item = new RemoteViews(
                              getApplicationContext().getPackageName(),
                              R.layout.test_widget_item
                      );
  
                      item.setTextViewText(
                              R.id.test_widget_item_feed,
                              iCursor.getString(iCursor.getColumnIndex("FED_TITLE"))
                          );
  
                      item.setTextViewText(
                              R.id.test_widget_item_title,
                              iCursor.getString(iCursor.getColumnIndex("ITM_TITLE"))
                          );
  
                      remoteViews.addView(R.id.test_widget_items, item);
  
                      iCursor.moveToNext();
                  }
              }
              iCursor.close();
  
  
              //
  
              appWidgetManager.updateAppWidget(widgetId, remoteViews);
          }
  
          stopSelf();
          super.onStart(intent, startId);
      }
  
      @Override
      public IBinder onBind(Intent intent) {
          return null;
      }
  }
  </code></pre>
  
  <p>This example shows only the layout "test_widget" without the added views, even though the sql returns results and the views are added.</p>
  
  <p>Working example (String only): </p>
  
  <pre><code>public class TestWidgetService extends Service {
  
      @Override
      public void onStart(Intent intent, int startId) {
  
          AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
  
          ComponentName thisWidget = new ComponentName(getApplicationContext(), TestWidget.class);
  
          int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
  
          for (int widgetId : allWidgetIds) {
  
              RemoteViews remoteViews = new RemoteViews(
                      getApplicationContext().getPackageName(),
                      R.layout.test_widget
                      );
  
              // get items
  
                      RemoteViews item = new RemoteViews(
                              getApplicationContext().getPackageName(),
                              R.layout.test_widget_item
                      );
  
                      item.setTextViewText(
                              R.id.test_widget_item_feed,
                              "feed"
                          );
  
                      item.setTextViewText(
                              R.id.test_widget_item_title,
                              "title"
                          );
  
                      remoteViews.addView(R.id.test_widget_items, item);
  
              //
  
              appWidgetManager.updateAppWidget(widgetId, remoteViews);
          }
  
          stopSelf();
          super.onStart(intent, startId);
      }
  
      @Override
      public IBinder onBind(Intent intent) {
          return null;
      }
  }
  </code></pre>
  
  <p>This working example shows the layout "test_widget" with the views inserted within the LinearLayout id "test_widget_items"</p>
  
  <p>I have spent the last week trying to get this widget to use sql results, anyone has any slight idea what might be wrong?</p>