我正在创建一个适用于UDP和MQTT通信的应用程序。 在后台服务中,大量数据同时从UDP通信中的另一台设备接收,并且每个数据都存储在SQLite数据库中,并且在数据库中对数据库中的不同表进行大量操作。
虽然有许多操作但仍会显示错误
SQLiteCantOpenDatabaseException at SQLiteDatabase db=this.getWritableDatabase();
并且应用程序被挂起并崩溃应用程序显示消息"不幸的是应用已经停止"。
所以我需要一个解决方案来改善这个并避免这个错误。
即使我已将每个操作放在try..catch...
块中,但它也会抛出错误。
和Logcat的错误是
05-18 10:34:23.402 1253-1253/com.nivida.smartnode E/SQLiteLog: (14) cannot open file at line 30052 of [b3bb660af9]
05-18 10:34:23.402 1253-1253/com.nivida.smartnode E/SQLiteLog: (14) os_unix.c:30052: (24) open(/storage/emulated/0/Smartnode/smartnodedb.db) -
05-18 10:34:23.411 1253-1253/com.nivida.smartnode E/SQLiteDatabase: Failed to open database '/storage/emulated/0/Smartnode/smartnodedb.db'. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1190)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:274)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) at com.nivida.smartnode.model.DatabaseHandler.setDimmerValue(DatabaseHandler.java:1616)