SQLiteOpenHelper getWritableDatabse () fails without exception

I have a very strange problem. From time to time, this only appears on a few devices. It seems that I canโ€™t play it when I want, but so many times that I think I know where I get it.

So, I have a Loader that connects to sqlite via singleton SQLiteOpenHelper :

 try { Log.i(TAG, "Get details offline / db helper: "+DatabaseHelper.getInstance(getContext())); SQLiteDatabase db=DatabaseHelper.getInstance(this.getContext()).getWritableDatabase(); Log.i(TAG, "Get details offline / db: "+db); //doing some work on the db... } catch(SQLiteException e){ e.printStackTrace(); return null; } catch(Exception e){ e.printStackTrace(); return null; //trying everything to grab some exception or whatever } 

My SQLiteOpenHelper looks something like this:

 public class DatabaseHelper extends SQLiteOpenHelper { private static DatabaseHelper mInstance = null; private static Context mCxt; public static DatabaseHelper getInstance(Context cxt) { //using app context as suggested by CommonsWare Log.i("DBHELPER1", "cxt"+mCxt+" / instance: "+mInstance); if (mInstance == null) { mInstance = new DatabaseHelper(cxt.getApplicationContext()); } Log.i("DBHELPER2", "cxt"+mCxt+" / instance: "+mInstance); mCxt = cxt; return mInstance; } //private constructor private DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); this.mCxt = context; } @Override public void onCreate(SQLiteDatabase db) { //some tables created here } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { //upgrade code here } } 

In most cases, this is really great. But from time to time I get a log like this:

 06-10 23:49:59.621: I/DBHELPER1(26499): cxtcom.myapp@407152c8 / instance: com.myapp.helpers.DatabaseHelper@40827560 06-10 23:49:59.631: I/DBHELPER2(26499): cxtcom.myapp@407152c8 / instance: com.myapp.helpers.DatabaseHelper@40827560 06-10 23:49:59.631: I/DetailsLoader(26499): Get event details offline / db helper: com.myapp.helpers.DatabaseHelper@40827560 06-10 23:49:59.631: I/DBHELPER1(26499): cxtcom.myapp@407152c8 / instance: com.myapp.helpers.DatabaseHelper@40827560 06-10 23:49:59.651: I/DBHELPER2(26499): cxtcom.myapp@407152c8 / instance: com.myapp.helpers.DatabaseHelper@40827560 

This line is Log.i(TAG, "Get details offline / db: "+db); never called! No exceptions, silence. In addition, the stream with Loader no longer works.

So, nothing is left behind the line:

 SQLiteDatabase db=DatabaseHelper.getInstance(this.getContext()).getWritableDatabase(); 

performed.

What could be wrong on this line?

+1
android sqlite sqliteopenhelper
Jun 10 2018-12-12T00:
source share

No one has answered this question yet.

See similar questions:

63
Using the Singleton Design Pattern for SQLiteDatabase
0
LoaderManager receives data offline and then over the Internet

or similar:

259
When does SQLiteOpenHelper onCreate () / onUpgrade () run?
13
Why doesn't my exception handler catch a SQLite SQLite insert error?
8
Android database is updated every time the application starts
5
Select a context context or application context to run SQLiteOpenHelper
four
Loadmanager onLoadFinished is not called
four
Android SQLite database exception - code 14 (cannot open database file)
one
Kill Network Service Discovery from AsyncTask when done without leaks
one
Android SQL Database - rawQuery () Source not found
0
I successfully passed text to my SQLite db, but my application crashes when I try to pass the selected checkboxes to SQLite db
0
dbHelper.getWritableDatabase () not working



All Articles