Jul 22, 2017 · 1 min read
Hullo Martin Thanks for the articleevrything works fine until i run the app and it indicates that
Attempt to invoke virtual method ‘com.xxx.room.database.MyDatabase com.xxx.room.App.getDB()’ on a null object reference
At “List<Product> products = App.get().getDB().productDao().getAll();”
// run the sentence in a new thread
new Thread(new Runnable() {
@Override
public void run() {
//AT THIS LEVEL IT IT INDICATES A NULL OBJECT
List<Product> products = App.get().getDB().productDao().getAll();
if (products.isEmpty()) {
retrieveProducts();
} else {
populateProducts(products);
}
}
}).start();Thank you so much