When I am trying to insert to data base log cat shows an error like java.lang.illegalstateexception database not open android.
But I have opened the db using
db = SQLiteDatabase.openDatabase(DATABASE_PATH, null,
SQLiteDatabase.OPEN_READWRITE);
The error is not occurring frequently.Anybody know the reason for this?
Try it like this:
if (!db.isOpen()) {
db = getApplicationContext().openOrCreateDatabase(DATABASE_PATH, SQLiteDatabase.OPEN_READWRITE, null);
}
try
DatabaseHelper dataHelper;
SQLiteDatabase mDb;
public DbManager openDB() throws SQLException {
mDb = dataHelper.getWritableDatabase();
return this;
}
and call this method where your re writing your current code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With