Esa Hannila
Esa Hannila

Reputation: 1318

SQLite database is locked?

I just tried to add row into SQLite database and text part includes "/" character.

This is how i do connection:

private SQLiteDatabase db;

this.db = this.getWritableDatabase();


    db.beginTransaction();

    ..............................
    insertion stuffs
    ..............................

    db.setTransactionSuccessful();
    db.endTransaction();

After that insert when I try to insert new row, app crashes and gives me this error on logcat:

08-24 19:01:09.477  27064-27064/? E/SQLiteLog﹕ (10) POSIX Error : 11 SQLite Error : 3850
08-24 19:01:09.477  27064-27064/? E/SQLiteLog﹕ (5) database is locked
Process: .MyService, PID: 17827
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode

Is it because slash characther or what? It worked well before that one row insertion or is my table corrupted?

Upvotes: 3

Views: 13502

Answers (1)

teoreda
teoreda

Reputation: 2570

I think you forget to close the connection to database, and invoke the method endTransaction().

Upvotes: 3

Related Questions