Answer the question
In order to leave comments, you need to log in
How to properly organize access to sqlite + android database?
Good afternoon.
There is an application that works closely (very very) with the database and with the Rest Service.
Often there is a situation when retrofit in the background executed a request (read the data from the service and tries to save them to the database) and at the same moment the user goes to another tab in the application and, accordingly, climbs into the database to get information, and the application crashes with an error :
java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at ru.fors.remsmed.db.DBHelper.getProfile(DBHelper.java:415)
SQLiteDatabase db = this.getWritableDatabase();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question