SQLite database is locked?

10,878

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

Share:
10,878
EspeH
Author by

EspeH

Software Engineer from finland. Self studied programming within 7 years. Completed studies of Bachelor Degree Programme at Oulu University of Applied Aciences in 1 year and 4 months. Studying AI at University of Oulu. Familiar with Angular HTML CSS jQuery Javascript Typescript Node.js Php Mysql MySql MariaDb MsSql MongoDb Java Kotlin C C++ C# xml python ruby Qt Express Jade Pug Stylus Ajax I'm also good at Picaxe Arduino Raspberry Pi Autodesk SolidWorks Vertex Linux Microsoft Office LTSpice Mathlab Windows 10 IoT Sensors

Updated on June 04, 2022

Comments

  • EspeH
    EspeH almost 2 years

    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?