Android数据库android.database.sqlite.SQLiteDiskIOException disk IO error
前言
最近使用SQLite,出现一些问题,因此整理于此,也摘抄了网上的其他问题。
好记性不如烂笔头
正文
异常:disk I/O error (code 4874 SQLITE_IOERR_SHMSIZE)
最近使用SQLite,出现如下异常。
SQLiteLog: (4874) disk I/O error SQLiteLog: (4874) os_unix.c:35328: (28) write(/data/user/0/com.media.scanner/databases/udisk.db-shm) - SQLiteDatabase: Failed to open database '/data/user/0/com.media.scanner/databases/udisk.db'. SQLiteDatabase: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 4874 SQLITE_IOERR_SHMSIZE): , while compiling: PRAGMA journal_mode SQLiteDatabase: at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) SQLiteDatabase: at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903) SQLiteDatabase: at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:648) SQLiteDatabase: at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:333)
出现异常后,导致数据无法写入。
通过查找前后日志,发现/data空间不足了,导致数据库无法打开错误。
DropBoxManagerService: java.io.IOException: write failed: ENOSPC (No space left on device) DropBoxManagerService: Caused by: android.system.ErrnoException: write failed: ENOSPC (No space left on device) epo : epo.c curl_easy_download 1266 fopen /data/vendor/gps/QEPOHAL.DAT failed.errno:28, reson: No space left on device installd: Device /data has 0 free; requested 204664012; needed 204664012 installd: Refusing to clear cached data in reserved space installd: Failed to free up 204664012 on /data; final free space 0: Success
出现“No space left on device”和“Failed to free up”等表示这个设备的/data分区已经满了。后面发现,我这是开启日志保存等功能,把data目录写满了。
其他异常:
SQLiteDiskIOException: disk I/O error (code 1802)
原因:
存储空间不足、文件读写权限不够,或者多线程操作(SQLite不支持多线程同时操作,自己枷锁)
SQLiteDiskIOException: disk I/O error (code 3850):
原因:
报此异常,一般就是多线程操作数据库时逻辑上的问题导致了锁异常。
参考文章
版权声明:125la.com站长 发表于 2021年5月12日 下午12:23。
转载请注明:Android数据库android.database.sqlite.SQLiteDiskIOException disk IO error | 125啦读书导航
转载请注明:Android数据库android.database.sqlite.SQLiteDiskIOException disk IO error | 125啦读书导航
相关文章
暂无评论...