2

I am implementing an app where I make database calls frequently.

I open the database using following code:

public DataBaseHelper open() throws SQLException {

      mDbHelper = new DatabaseHelper(this.mCtx);
      this.mDb = mDbHelper.getWritableDatabase();
      return this;
 }

but I get database locked exception in the following line:

 this.mDb = mDbHelper.getWritableDatabase();

Please help me fix this exception.

Thanks in advance

Abhilasha
  • 929
  • 1
  • 17
  • 37
kiran
  • 3,244
  • 7
  • 34
  • 57
  • Can you make DataBaseHelper class static? Seems you are creating many connections. Another nice way would be to set some connection pooling mechanism. – Shailesh Jul 17 '12 at 12:00

1 Answers1

2

this problem arises when you use several connections with your database. try to avoid creating multiple connections to the database and use the one with all your functions

Database locked exception

Community
  • 1
  • 1
Vinay W
  • 9,912
  • 8
  • 41
  • 47