数据库无法打开,点击答题后闪退

衍小明 Android 项目开发实战:... 2018年04月23日提问

  • 0 回答
  • 347 浏览

Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database

网上有说是因为新版本的Android没有获取 data 目录下的权限,加了

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

这个权限之后还是不行,求大神解答

FATAL EXCEPTION: main
                  Process: gd.wm.exam, PID: 30636
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{gd.wm.exam/gd.wm.exam.ExamActivity}: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                      at android.app.ActivityThread.-wrap11(Unknown Source:0)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                      at android.os.Handler.dispatchMessage(Handler.java:106)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6494)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                   Caused by: 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:210)
                      at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:194)
                      at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:493)
                      at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:200)
                      at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:192)
                      at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:864)
                      at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:849)
                      at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:750)
                      at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:699)
                      at gd.wm.exam.DBServise.<init>(DBServise.java:17)
                      at gd.wm.exam.ExamActivity.onCreate(ExamActivity.java:24)
                      at android.app.Activity.performCreate(Activity.java:7009)
                      at android.app.Activity.performCreate(Activity.java:7000)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)