我刚刚尝试将行添加到 SQLite 数据库中,文本部分包含“/”字符。
我是这样连接的:
private SQLiteDatabase db;
this.db = this.getWritableDatabase();
db.beginTransaction();
..............................
insertion stuffs
..............................
db.setTransactionSuccessful();
db.endTransaction();
插入之后,当我尝试插入新行时,应用程序崩溃并在 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
是因为斜线字符还是什么?它在插入一行之前运行良好,还是我的表已损坏?
最佳答案
我想你忘了close the connection to database , 并调用方法 endTransaction() .
关于android - SQLite 数据库被锁定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32186033/