title: Using room persistence when trying to fetch items or insert returns null database
body: <p>Working with room persistence, when trying to get the database to insert or make select in the items, the error appears:</p>
  
  <blockquote>
    <p>AppDataBase.getMovieDao()' on a null object reference</p>
  </blockquote>
  
  <p>The classes related to the process are as follows:</p>
  
  <p>AppDataBase class:</p>
  
  <pre><code>@Database(entities = {Movies.class}, version = 1)
  public abstract class AppDataBase extends RoomDatabase {
  
      public static final String DB_NAME = "Movies";
      private static AppDataBase INSTANCE;
  
      public static AppDataBase getDataBase(Context context){
          if (INSTANCE == null){
              INSTANCE = Room.databaseBuilder(context.getApplicationContext(),AppDataBase.class,DB_NAME).build();
          }
          return INSTANCE;
      }
  
      public abstract MovieDao getMovieDao();
  }
  </code></pre>
  
  <p>Dao Class:</p>
  
  <pre><code>@Dao
  public interface MovieDao {
  
      @Insert
      void insertAll(Movies movies);
  
      @Update
      void updateAll(Movies... notes);
  
      @Query("SELECT * FROM moviestb")
      List&lt;Movies&gt; getAll();
  
      @Delete
      void deleteAll(Movies... notes);
  
  }
  </code></pre>
  
  <p>Entity class:</p>
  
  <pre><code>@Entity(tableName = "moviestb")
  public class Movies {
  
      @PrimaryKey(autoGenerate = true)
      @ColumnInfo(name = "idmovie")
      private long id;
  
      @ColumnInfo(name = "titlemovie")
      private String titlemovie;
  ........
  }
  </code></pre>
  
  <p>Searching for the registrations:</p>
  
  <pre><code>public void loadFromDB(){
      db.getDataBase(view.getContext());
      if(db.getMovieDao().getAll().size() &gt; 0){
          adapter.setResults(db.getMovieDao().getAll());
      }else{
          Toast.makeText(view.getContext(),"Não há filmes cadastrados",Toast.LENGTH_SHORT).show();
          view.getActivity().finish();
      }
  }
  </code></pre>
  
  <p>Insert:</p>
  
  <pre><code>public View.OnClickListener onSaveClick(final String plot, final String diretor, final String autor,
                                              final String nome, final String tipo, final String ano, final String ator, final String imdb) {
          return new View.OnClickListener() {
              @Override
              public void onClick(View itemView) {
                  db.getDataBase(view.getContext());
                  Movies movies = new Movies(nome,plot,imdb,"",ator,ano,tipo,diretor,autor);
                  new InsertAsyncTask(db).execute(movies);
  
              }
          };
      }
  
      private class InsertAsyncTask extends AsyncTask&lt;Movies,Void,Void&gt;{
          private AppDataBase db;
          public InsertAsyncTask(AppDataBase appDataBase) {
              db = appDataBase;
          }
  
          @Override
          protected Void doInBackground(Movies... params) {
              db.getMovieDao().insertAll(params[0]);
              return null;
          }
      }
  </code></pre>
  
  <p>Searching all:</p>
  
  <pre><code>public void loadFromDB(){
      db.getDataBase(view.getContext());
      if(db.getMovieDao().getAll().size() &gt; 0){
          adapter.setResults(db.getMovieDao().getAll());
      }else{
          Toast.makeText(view.getContext(),"Não há filmes cadastrados",Toast.LENGTH_SHORT).show();
          view.getActivity().finish();
      }
  }
  </code></pre>
  
  <p>The crash occurs while fetching the database, what am I doing wrong? thank you!</p>