在我的应用中,我有SyncAdapter
使用ContentProvider
将数据放入SQLiteDatabase。几个月来,一切都运转良好。在我添加了第二种方法来更新来自GCM推送通知的ContentProvider后,我开始收到某些用户的崩溃报告,例如
android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 3850)
OR
android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 778)
以及与sqlite相关的其他几个例外。
虽然我听说Sqlite是同步的,我们不必担心,但我确实得到了这些错误,指出我需要以某种方式进行同步。有人处理过这个问题吗?
编辑: 这是一个示例堆栈跟踪
android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 778)
1
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
2
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:906)
3
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
4
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
5
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
6
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1365)
7
at com.makanstudios.conscious.provider.ConsciousProvider.doInsert(ConsciousProvider.java:225)
8
at com.kaciula.utils.provider.BasicContentProvider.insert(BasicContentProvider.java:80)
9
at android.content.ContentProvider$Transport.insert(ContentProvider.java:201)
10
at android.content.ContentResolver.insert(ContentResolver.java:866)
11
at com.makanstudios.conscious.net.DatabaseHandler.updateStatsCount(DatabaseHandler.java:351)
12
at com.makanstudios.conscious.net.DatabaseHandler.updateStatsCount(DatabaseHandler.java:362)
13
at com.makanstudios.conscious.gcm.GCMIntentService.onMessage(GCMIntentService.java:124)
14
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
15
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
16
at android.os.Handler.dispatchMessage(Handler.java:99)
17
at android.os.Looper.loop(Looper.java:137)
18
at android.os.HandlerThread.run(HandlerThread.java:60)
另一个示例堆栈跟踪:
0
android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode.
1
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
2
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:318)
3
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:229)
4
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
5
at android.database.sqlite.SQLiteConnectionPool.reconfigure(SQLiteConnectionPool.java:339)
6
at android.database.sqlite.SQLiteDatabase.reopenReadWrite(SQLiteDatabase.java:832)
7
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:213)
8
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
9
at com.kaciula.utils.provider.BasicContentProvider.insert(BasicContentProvider.java:76)
10
at android.content.ContentProvider$Transport.insert(ContentProvider.java:201)
11
at android.content.ContentResolver.insert(ContentResolver.java:869)
12
at com.makanstudios.conscious.net.DatabaseHandler.updateStatsCount(DatabaseHandler.java:351)
13
at com.makanstudios.conscious.net.DatabaseHandler.updateStatsCount(DatabaseHandler.java:362)
14
at com.makanstudios.conscious.gcm.GCMIntentService.onMessage(GCMIntentService.java:124)
15
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
16
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
17
at android.os.Handler.dispatchMessage(Handler.java:99)
18
at android.os.Looper.loop(Looper.java:137)
19
at android.os.HandlerThread.run(HandlerThread.java:60)
答案 0 :(得分:0)
只需在内容提供商代码中使用一个帮助程序即可。因此,始终将1个帮助程序连接到1个数据库,您将不会遇到任何问题。
如果您不提供对其他应用程序的访问权限,则无需使用内容提供商。
在我决定切换到ORMLite之前,我一直在使用内容提供商。到目前为止,它在我的所有项目中都运行良好。也许检查一下。