无法打开数据库

时间:2014-11-27 07:54:45

标签: android database

很抱歉再次击败这匹马 - 我正在测试一个在小型设备上运行完美但却无法在标签上创建或打开数据库的应用程序。该应用程序在三星S3 mini上运行良好,但我现在正在三星Tab上试用它。

相关代码段

private static String DB_PATH =" /data/data/com.example.squashbotv2/databases /" ;; private static String DB_NAME =" squashbot.db&#34 ;;

    String myPath = DB_PATH + DB_NAME;
    checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

logcat的

11-27 10:46:21.772: D/dalvikvm(3733): GC_FOR_ALLOC freed 103K, 4% free 6830K/7047K, paused 20ms
11-27 10:46:21.788: D/dalvikvm(3733): GC_FOR_ALLOC freed 2K, 4% free 7130K/7367K, paused 16ms
11-27 10:46:21.795: I/SqliteDatabaseCpp(3733): sqlite returned: error code = 14, msg = cannot open file at line 27862 of [ed759d5a9e], db=/data/data/com.example.squashbotv2/databases/squashbot.db
11-27 10:46:21.795: I/SqliteDatabaseCpp(3733): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27862 - "" errno=2 path=/data/data/com.example.squashbotv2/databases/squashbot.db, db=/data/data/com.example.squashbotv2/databases/squashbot.db
11-27 10:46:21.795: E/SqliteDatabaseCpp(3733): sqlite3_open_v2("/data/data/com.example.squashbotv2/databases/squashbot.db", &handle, 1, NULL) failed
11-27 10:46:21.803: E/SQLiteDatabase(3733): Failed to open the database. closing it.
11-27 10:46:21.803: E/SQLiteDatabase(3733): android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1123)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1074)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1050)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at database.Database.checkDataBase(Database.java:139)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at database.Database.create(Database.java:107)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at com.example.squashbotv2.Dashboard.onCreate(Dashboard.java:37)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.Activity.performCreate(Activity.java:4465)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.os.Looper.loop(Looper.java:137)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at android.app.ActivityThread.main(ActivityThread.java:4514)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at java.lang.reflect.Method.invokeNative(Native Method)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at java.lang.reflect.Method.invoke(Method.java:511)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
11-27 10:46:21.803: E/SQLiteDatabase(3733):     at dalvik.system.NativeStart.main(Native Method)
11-27 10:46:21.866: I/SqliteDatabaseCpp(3733): sqlite returned: error code = 1, msg = no such table: android_metadata, db=/data/data/com.example.squashbotv2/databases/squashbot.db
11-27 10:46:21.866: E/SqliteDatabaseCpp(3733): SELECT locale FROM android_metadata failed
11-27 10:46:21.866: E/SQLiteDatabase(3733): Failed to open the database. closing it.
11-27 10:46:21.866: E/SQLiteDatabase(3733): android.database.sqlite.SQLiteException: no such table: android_metadata
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.setLocale_(SQLiteDatabase.java:2205)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:2193)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1124)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1074)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1050)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at database.Database.open(Database.java:187)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at com.example.squashbotv2.Dashboard.onCreate(Dashboard.java:47)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.Activity.performCreate(Activity.java:4465)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.os.Looper.loop(Looper.java:137)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at android.app.ActivityThread.main(ActivityThread.java:4514)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at java.lang.reflect.Method.invokeNative(Native Method)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at java.lang.reflect.Method.invoke(Method.java:511)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
11-27 10:46:21.866: E/SQLiteDatabase(3733):     at dalvik.system.NativeStart.main(Native Method)
11-27 10:46:21.866: D/AndroidRuntime(3733): Shutting down VM
11-27 10:46:21.866: W/dalvikvm(3733): threadid=1: thread exiting with uncaught exception (group=0x40be51f8)
11-27 10:46:21.873: E/AndroidRuntime(3733): FATAL EXCEPTION: main
11-27 10:46:21.873: E/AndroidRuntime(3733): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.squashbotv2/com.example.squashbotv2.Dashboard}: android.database.sqlite.SQLiteException: no such table: android_metadata
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.os.Looper.loop(Looper.java:137)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.ActivityThread.main(ActivityThread.java:4514)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at java.lang.reflect.Method.invokeNative(Native Method)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at java.lang.reflect.Method.invoke(Method.java:511)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at dalvik.system.NativeStart.main(Native Method)
11-27 10:46:21.873: E/AndroidRuntime(3733): Caused by: android.database.sqlite.SQLiteException: no such table: android_metadata
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.database.sqlite.SQLiteDatabase.setLocale_(SQLiteDatabase.java:2205)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:2193)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1124)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1074)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1050)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at database.Database.open(Database.java:187)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at com.example.squashbotv2.Dashboard.onCreate(Dashboard.java:47)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.Activity.performCreate(Activity.java:4465)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-27 10:46:21.873: E/AndroidRuntime(3733):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-27 10:46:21.873: E/AndroidRuntime(3733):     ... 11 more

我试过了:

  • 清洗
  • 卸载&重新安装

在线搜索类似的查询似乎并不是一个可靠的解决方案,似乎这个问题可能是由许多不同的事情引起的。有人可以帮忙吗?

提前完成

0 个答案:

没有答案