SQLiteDatabase close() function causing NullPointerException when multiple threads

I have your answers! Never close the db. It is that simple. Make sure you only have one, repeat, *one Helper instance per application. Share it with all threads. http://www.touchlab.co/blog/single-sqlite-connection/ Here’s some more info on the internals of sqlite and locking: http://www.touchlab.co/blog/android-sqlite-locking/

NullPointerException while trying to access @Inject bean in constructor

You’re expecting that the injected dependency is available before the bean is constructed. You’re expecting that it works like this: RequestBean requestBean; requestBean.sessionBean = sessionBean; // Injection. requestBean = new RequestBean(); // Constructor invoked. This is however not true and technically impossible. The dependencies are injected after construction. RequestBean requestBean; requestBean = new RequestBean(); // … Read more

Is it okay to throw NullPointerException programmatically? [closed]

I would recommend you never throw NullPointerException by yourself. The main reason not to do this, as Thorbjørn Ravn Andersen says in a comment below, is that you don’t wan’t to mix ‘real, bad NPEs’ with NPEs thrown intentionally. So, until you’re confident that you’re able to recognize ‘valid’ NPE, I’d recommend to use IllegalArgumentException … Read more