KhAn Han
KhAn Han
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

    KhAn Han

    Written by

    KhAn Han

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade