Android的SQLiteDiskIOException在getReadableDatabase(),native_setLocale,SQLiteOpenHelper [英] Android SQLiteDiskIOException in getReadableDatabase(), native_setLocale, SQLiteOpenHelper

查看:254
本文介绍了Android的SQLiteDiskIOException在getReadableDatabase(),native_setLocale,SQLiteOpenHelper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我碰到使用SQLiteOpenHelper连接的问题。
很少有用户报告我无法重现错误:

  android.database.sqlite.SQLiteDiskIOException:磁盘I / O错误
在android.database.sqlite.SQLiteDatabase.native_setLocale(本机方法)
在android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1987)
在android.database.sqlite.SQLiteDatabase<&初始化GT;(SQLiteDatabase.java:1855)
在android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
在android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)

我的实现云:

 公共类SqliteDatabase扩展SQLiteOpenHelper
{
    公共SqliteDatabase(上下文的背景下,字符串DBNAME,INT dbVersion)
    {
        超(背景下,数据库名,空,dbVersion);
        this.context =背景;
        this.dbName = DBNAME;
        this.dbVersion = dbVersion;
    }
    (......)
}

所以没有什么特别在这里。唯一的例外是getReadableDatabase()调用抛出后,为可见的堆栈。

请注意,这个类是由多个线程accesed,但访问是完全同步的(锁+只有一个,同一个类的实例)。应用程序可以移动到SD卡(也许这就是问题?)。

不幸的是,我不知道在哪个设备/ Android版本出现问题(平台:其他在谷歌播放控制台),但是做了一些谷歌搜索后,我怀疑它的Andr​​oid V2.2.1

任何想法?我知道,这个问题是更不常见,但我还没有找到任何解决办法尚未...


解决方案

  1. 这种类型的错误大多发生,当你在同一时间执行两个操作。

  2. 当您关闭或错误地打开数据库。例如,靠近你的数据库,然后您炒掉查询。

Recently I've run into a problem connected with using SQLiteOpenHelper. Few users reported the error I can't reproduce:

android.database.sqlite.SQLiteDiskIOException: disk I/O error
at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1987)
at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1855)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)

My implementation goes:

public class SqliteDatabase extends SQLiteOpenHelper
{
    public SqliteDatabase(Context context, String dbName, int dbVersion)
    {
        super(context, dbName, null, dbVersion);
        this.context = context;
        this.dbName = dbName;
        this.dbVersion = dbVersion;
    }
    (...)
}

So nothing special here. The exception is thrown after getReadableDatabase() invocation, as visible in stack.

Note that this class is accesed by many threads, but the access is totally synchronized (locks + only one, the same class instance). The Application can be moved to sdcard (maybe that's the issue?).

Unfortunately I do not know on which device / Android version the problem occurs (platform: other in Google Play console), but after doing some googling I suspect it's Android v2.2.1.

Any ideas? I know that the problem is more-less common, but I have not found any solution yet...

解决方案

  1. This type of error occured mostly when you perform two operations at the same time.
  2. When you close or open database by mistake. For example, when close your database and then you fire your query.

这篇关于Android的SQLiteDiskIOException在getReadableDatabase(),native_setLocale,SQLiteOpenHelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆