A
A
Alexander Popov2015-09-26 17:12:51
Android
Alexander Popov, 2015-09-26 17:12:51

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)

here in this place: What to do? p.s. Thanks in advance. pps At the request of the customer, I can not show progressDialog'i, he wants all work with inf. was in the background :( SQLiteDatabase db = this.getWritableDatabase();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
belozerow, 2015-09-26
@Chuffey

ContentProvider
CursorLoader

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question