android.database.sqlite.SQLiteDiskIOException:错误代码10:磁盘I / O错误

时间:2012-04-11 08:44:46

标签: android sqlite

当我使用Sqlite缓存数据时,我遇到了这个问题。我已经检查了其他类似问题,例如this,但我无法解决。

我的代码是

public int insertByTransaction(List<CacheContent> cacheContentList) {
    android.util.Log.v(com.usher.constants.Constants.TAG_CACHE, "Using transaction to insert records...");
    int count = 0;
    db = getWritableDatabase();
    if (db == null || db.isOpen() == false || cacheContentList == null) {
        return -1;
    }
    // begin transaction
    db.beginTransaction();
    try {
        long result = -1;
        for (CacheContent cacheContent : cacheContentList) {
            ContentValues values = new ContentValues();
            values.put(CacheContent.ID, cacheContent.getId());
            values.put(CacheContent.URL_HASH_CODE, cacheContent.getUrl_hash_code());
            values.put(CacheContent.SERVICE_CONTENT, cacheContent.getService_content());
            values.put(CacheContent.LAST_MODIFIED, cacheContent.getLast_modified());
            values.put(CacheContent.EVENT_BEGIN_TIME, cacheContent.getEvent_start_time());
            result = db.insert(TABLE_NAME, null, values);
            if (result != -1) {
                count++;
            }
        }
        // set Transaction Successful
        db.setTransactionSuccessful();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // end Transaction
        db.endTransaction();
    }
    return count;
}

logcat /错误信息是

sqlite returned: error code = 1802, msg = statement aborts at 11: [INSERT INTO  .....] Error inserting  
android.database.sqlite.SQLiteDiskIOException: error code 10: disk I/O error
at android.database.sqlite.SQLiteStatement.native_executeInsert(Native Method)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:112)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1737)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1610)
at com.usher.services.DBHelper.insertByTransaction(DBHelper.java:118)
at com.usher.services.ServicesResultCache.addCacheOneByOne(ServicesResultCache.java:293)
at com.usher.services.EventService.doStartService(EventService.java:88)
at com.usher.services.DataServiceImpl$1.call(DataServiceImpl.java:187)
at com.usher.services.DataServiceImpl$1.call(DataServiceImpl.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
at java.lang.Thread.run(Thread.java:1020)

0 个答案:

没有答案