title: Android - How to access data from the Room database to the Stack Widget
body: <p>I just learned about Android and here I have homework. I tried to make a stack widget which accesses a data from the database Room, here I try to access it but the data does not appear, I am confused about the solution and still do not understand</p>
  
  <pre><code>private Context context;
  private List&lt;MovieEntity&gt; list = new ArrayList&lt;&gt;();
  
  public StackRemoteViewsFactory(Context context) {
      this.context = context;
  }
  
  @Override
  public void onCreate() {
  
  }
  
  @Override
  public void onDataSetChanged() {
      new AsyncTask&lt;Context, Void, List&lt;MovieEntity&gt;&gt;() {
  
          @Override
          protected List&lt;MovieEntity&gt; doInBackground(Context... contexts) {
              AppDatabase database = AppDatabase.getInstance(context);
              list = database.favoriteDao().getMovies();
  
              return list;
          }
  
          @Override
          protected void onPostExecute(List&lt;MovieEntity&gt; movieEntities) {
              super.onPostExecute(movieEntities);
          }
  
      }.execute(context);
  }
  
  @Override
  public RemoteViews getViewAt(int position) {
      RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.item_widget);
  
      for (MovieEntity movieEntity : list) {
          Bitmap bmp = null;
          try {
              bmp = Glide.with(context)
                      .asBitmap()
                      .load("https://image.tmdb.org/t/p/w300_and_h450_bestv2" + movieEntity.getPosterPath())
                      .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get();
  
          } catch (Exception e) {
              Log.d("ERROR", "error");
          }
  
  
          rv.setTextViewText(R.id.txt_item_title, movieEntity.getTitle());
          rv.setImageViewBitmap(R.id.image_item_poster, bmp);
      }
      return rv;
  
  }
  
  @Override
  public int getViewTypeCount() {
      return 1;
  }
  </code></pre>