代码14无法打开数据库

时间:2014-10-09 16:03:32

标签: java android database sqlite

我有一个很小的CRUD项目来学习android开发我在openOrCreateDatabase时发现错误。

我缺少什么?

 String sqldb_location = System.getProperty("user.dir");
        File sqldb_path = new File(sqldb_location, sqldb_name);
        boolean sqldb_exists = new File(sqldb_path.getAbsolutePath()).exists();
        if(!sqldb_exists)
        {
            sqldb = SQLiteDatabase.openOrCreateDatabase(sqldb_path.getAbsolutePath(), null, null);
            sqldb_query = "CREATE TABLE IF NOT EXISTS tblStudents (_id INTEGER PRIMARY KEY AUTOINCREMENT, Name VARCHAR, LastName VARCHAR, Age INT);";
            sqldb.execSQL(sqldb_query);
            sqldb_message = "Database: " + sqldb_name + " created";
        }
        else
        {
            sqldb = openDatabase(sqldb_path.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE);
            sqldb_message = "Database: " + sqldb_name + " opened";
        }

logcat的

10-09 20:59:14.831 23434-23434 / com.example.solutionwares.myapplication I / SELinux:功能:selinux_android_load_priority [0],没有sepolicy文件。 10-09 20:59:14.831 23434-23434 / com.example.solutionwares.myapplication I / SELinux:功能:selinux_android_load_priority,加载版本为VE = SEPF_GT-I9505_4.4.2_0017 10-09 20:59:14.831 23434-23434 / com.example.solutionwares.myapplication I / SELinux:selinux_android_seapp_context_reload:seapp_contexts文件从/ data / security / spota / seapp_contexts加载 10-09 20:59:14.841 23434-23434 / com.example.solutionwares.myapplication D / dalvikvm:延迟启用CheckJNI 10-09 20:59:14.951 23434-23434 / com.example.solutionwares.myapplication E / SQLiteLog:(14)无法打开[00bb9c9ce4]第32554行的文件 10-09 20:59:14.951 23434-23434 / com.example.solutionwares.myapplication E / SQLiteLog:(14)os_unix.c:32554:(2)open(/ dbEMS) - 10-09 20:59:14.951 23434-23434 / com.example.solutionwares.myapplication E / SQLiteDatabase:无法打开数据库' / dbEMS'。     android.database.sqlite.SQLiteCantOpenDatabaseException:未知错误(代码14):无法打开数据库             在android.database.sqlite.SQLiteConnection.nativeOpen(本机方法)             在android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:342)             在android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:232)             在android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)             在android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)             在android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)             在android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:891)             在android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:859)             在android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)             在android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:719)             在Repository.Database.CreateDatabase(Database.java:47)             在Repository.Database。(Database.java:24)             在Repository.Students。(Students.java:14)             在com.example.solutionwares.myapplication.MyActivity。(MyActivity.java:24)             at java.lang.Class.newInstanceImpl(Native Method)             在java.lang.Class.newInstance(Class.java:1208)             在android.app.Instrumentation.newActivity(Instrumentation.java:1079)             在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)             在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)             在android.app.ActivityThread.access $ 900(ActivityThread.java:161)             在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1265)             在android.os.Handler.dispatchMessage(Handler.java:102)             在android.os.Looper.loop(Looper.java:157)             在android.app.ActivityThread.main(ActivityThread.java:5356)             at java.lang.reflect.Method.invokeNative(Native Method)             在java.lang.reflect.Method.invoke(Method.java:515)             在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1265)             在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)             at dalvik.system.NativeStart.main(Native Method) 10-09 20:59:14.951 23434-23434 / com.example.solutionwares.myapplication W / ApplicationPackageManager:getCSCPackageItemText() 10-09 20:59:15.021 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:获取MotionRecognitionManager 10-09 20:59:15.041 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用onVisibilityChanged(),可见性:4 10-09 20:59:15.041 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 20:59:15.051 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用onVisibilityChanged(),可见性:0 10-09 20:59:15.051 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 20:59:15.071 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 20:59:15.091 23434-23434 / com.example.solutionwares.myapplication I / Adreno-EGL :: EGL 1.4 QUALCOMM build:(CL3869936)     OpenGL ES着色器编译器版本:17.01.11.SPL     建造日期:2014年1月17日星期五     当地分行:     远程分支:     本地补丁:     重建分支: 10-09 20:59:15.131 23434-23434 / com.example.solutionwares.myapplication D / OpenGLRenderer:启用调试模式0 10-09 20:59:15.131 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 20:59:15.191 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 20:59:15.201 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 20:59:15.381 23434-23434 / com.example.solutionwares.myapplication D / AbsListView:调用unregisterIRListener() 10-09 21:07:56.179 24643-24643 / com.example.solutionwares.myapplication I / SELinux:功能:selinux_android_load_priority [0],没有sepolicy文件。 10-09 21:07:56.179 24643-24643 / com.example.solutionwares.myapplication I / SELinux:功能:selinux_android_load_priority,加载版本为VE = SEPF_GT-I9505_4.4.2_0017 10-09 21:07:56.179 24643-24643 / com.example.solutionwares.myapplication I / SELinux:selinux_android_seapp_context_reload:seapp_contexts文件从/ data / security / spota / seapp_contexts加载 10-09 21:07:56.189 24643-24643 / com.example.solutionwares.myapplication D / dalvikvm:延迟启用CheckJNI

10-09 21:07:56.289  24643-24643/com.example.solutionwares.myapplication E/SQLiteLog﹕ (14) cannot open file at line 32554 of [00bb9c9ce4]
10-09 21:07:56.289  24643-24643/com.example.solutionwares.myapplication E/SQLiteLog﹕ (14) os_unix.c:32554: (2) open(/dbEMS) -
10-09 21:07:56.289  24643-24643/com.example.solutionwares.myapplication E/SQLiteDatabase﹕ Failed to open database '/dbEMS'.
    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:342)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:232)
            at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
            at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:891)
            at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:859)
            at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
            at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:719)
            at Repository.Database.CreateDatabase(Database.java:47)
            at Repository.Database.<init>(Database.java:24)
            at Repository.Students.<init>(Students.java:14)
            at com.example.solutionwares.myapplication.MyActivity.<init>(MyActivity.java:24)
            at java.lang.Class.newInstanceImpl(Native Method)
            at java.lang.Class.newInstance(Class.java:1208)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
            at android.app.ActivityThread.access$900(ActivityThread.java:161)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5356)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
10-09 21:07:56.289  24643-24643/com.example.solutionwares.myapplication W/ApplicationPackageManager﹕ getCSCPackageItemText()
10-09 21:07:56.379  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ Get MotionRecognitionManager
10-09 21:07:56.389  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ onVisibilityChanged() is called, visibility : 4
10-09 21:07:56.389  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:07:56.399  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ onVisibilityChanged() is called, visibility : 0
10-09 21:07:56.399  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:07:56.419  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:07:56.450  24643-24643/com.example.solutionwares.myapplication I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:  (CL3869936)
    OpenGL ES Shader Compiler Version: 17.01.11.SPL
    Build Date: 01/17/14 Fri
    Local Branch:
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
10-09 21:07:56.500  24643-24643/com.example.solutionwares.myapplication D/OpenGLRenderer﹕ Enabling debug mode 0
10-09 21:07:56.510  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:11:14.793  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:11:14.923  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:11:14.933  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called
10-09 21:12:15.052  24643-24643/com.example.solutionwares.myapplication W/IInputConnectionWrapper﹕ getTextBeforeCursor on inactive InputConnection
10-09 21:12:15.062  24643-24643/com.example.solutionwares.myapplication W/IInputConnectionWrapper﹕ getCursorCapsMode on inactive InputConnection
10-09 21:12:15.072  24643-24643/com.example.solutionwares.myapplication W/IInputConnectionWrapper﹕ getCursorCapsMode on inactive InputConnection
10-09 21:12:20.928  24643-24643/com.example.solutionwares.myapplication D/AbsListView﹕ unregisterIRListener() is called

0 个答案:

没有答案