频繁访问sqlite数据库报错 ,线程访问数据库

android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:845)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:144)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
at android.content.ContentResolver.query(ContentResolver.java:480)
at android.content.ContentResolver.query(ContentResolver.java:404)

参考

1.http://www.liuhaihua.cn/archives/203704.html



android.database.CursorWindowAllocationException: Cursor window could not be created from binder.
at android.database.CursorWindow.(CursorWindow.java:133)
at android.database.CursorWindow.(CursorWindow.java:41)
at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:681)
at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:679)
at android.database.BulkCursorDescriptor.readFromParcel(BulkCursorDescriptor.java:75)
at android.database.BulkCursorDescriptor$1.createFromParcel(BulkCursorDescriptor.java:34)
at android.database.BulkCursorDescriptor$1.createFromParcel(BulkCursorDescriptor.java:30)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:416)
at android.content.ContentResolver.query(ContentResolver.java:461)
at android.content.ContentResolver.query(ContentResolver.java:404)

,try-finally并不能保证query打开游标在dosomething时,被其他线程再次调用query打开游标。所以当遇到存在多线程的调用时必须对游标打开到关闭时间段添加锁,即这里是对try-finally块加锁。

http://www.2cto.com/kf/201408/329574.html

你可能感兴趣的:(频繁访问sqlite数据库报错 ,线程访问数据库)