没有信息存储在SQLite数据库

时间:2015-10-31 19:45:49

标签: java android database sqlite

我一直在使用Login-Register应用程序,目前正面临一些问题。

我遇到的问题是,即使我能够输入信息并点击"注册"按钮。
每当我按下"登录"按钮,应用程序将始终显示"不幸的是,此应用程序已停止"。

有谁知道为什么并可以提供帮助?
我希望尽快得到帮助,因为我正在为我的最后一年项目做这件事。

logcat的:

11-01 02:52:06.893  31336-31336/? E/Zygote﹕ MountEmulatedStorage()
11-01 02:52:06.893  31336-31336/? E/Zygote﹕ v2
11-01 02:52:06.893  31336-31336/? I/libpersona﹕ KNOX_SDCARD checking this for 10139
11-01 02:52:06.893  31336-31336/? I/libpersona﹕ KNOX_SDCARD not a persona
11-01 02:52:06.893  31336-31336/? I/SELinux﹕ Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_GT-I9505_5.0.1 ver=27
11-01 02:52:06.893  31336-31336/? I/SELinux﹕ Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9505_5.0.1-1_0032
11-01 02:52:06.903  31336-31336/edu.np.ece.information E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
11-01 02:52:06.903  31336-31336/edu.np.ece.information I/art﹕ Late-enabling -Xcheck:jni
11-01 02:52:06.933  31336-31343/edu.np.ece.information E/art﹕ Failed writing handshake bytes (-1 of 14): Broken pipe
11-01 02:52:06.933  31336-31343/edu.np.ece.information I/art﹕ Debugger is no longer active
11-01 02:52:06.983  31336-31336/edu.np.ece.information D/ResourcesManager﹕ creating new AssetManager and set to /data/app/edu.np.ece.information-1/base.apk
11-01 02:52:07.203  31336-31336/edu.np.ece.information D/Activity﹕ performCreate Call secproduct feature valuefalse
11-01 02:52:07.203  31336-31336/edu.np.ece.information D/Activity﹕ performCreate Call debug elastic valuetrue
11-01 02:52:07.213  31336-31353/edu.np.ece.information D/OpenGLRenderer﹕ Render dirty regions requested: true
11-01 02:52:07.263  31336-31353/edu.np.ece.information I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
    OpenGL ES Shader Compiler Version: E031.25.03.06
    Build Date: 01/24/15 Sat
    Local Branch: AF11_RB1_AU15
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
11-01 02:52:07.263  31336-31353/edu.np.ece.information I/OpenGLRenderer﹕ Initialized EGL, version 1.4
11-01 02:52:07.293  31336-31353/edu.np.ece.information D/OpenGLRenderer﹕ Enabling debug mode 0
11-01 02:52:07.593  31336-31336/edu.np.ece.information I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@1ddca8e7 time:4384368
11-01 02:52:11.237  31336-31336/edu.np.ece.information D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN
11-01 02:52:14.110  31336-31336/edu.np.ece.information D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN
11-01 02:52:16.302  31336-31336/edu.np.ece.information D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN
11-01 02:52:16.372  31336-31336/edu.np.ece.information E/SQLiteLog﹕ (1) no such column: pass
11-01 02:52:16.372  31336-31336/edu.np.ece.information D/AndroidRuntime﹕ Shutting down VM
11-01 02:52:16.372  31336-31336/edu.np.ece.information E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: edu.np.ece.information, PID: 31336
    java.lang.IllegalStateException: Could not execute method of the activity
            at android.view.View$1.onClick(View.java:4253)
            at android.view.View.performClick(View.java:5197)
            at android.view.View$PerformClick.run(View.java:20926)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:145)
            at android.app.ActivityThread.main(ActivityThread.java:5942)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4248)
            at android.view.View.performClick(View.java:5197)
            at android.view.View$PerformClick.run(View.java:20926)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:145)
            at android.app.ActivityThread.main(ActivityThread.java:5942)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
     Caused by: android.database.sqlite.SQLiteException: no such column: pass (code 1): , while compiling: select uname, pass from information
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1093)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:670)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
            at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
            at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
            at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1440)
            at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1379)
            at edu.np.ece.information.DatabaseHelper.searchPass(DatabaseHelper.java:68)
            at edu.np.ece.information.MainActivity.onButtonClick(MainActivity.java:38)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4248)
            at android.view.View.performClick(View.java:5197)
            at android.view.View$PerformClick.run(View.java:20926)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:145)
            at android.app.ActivityThread.main(ActivityThread.java:5942)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

这是项目文件夹链接: https://drive.google.com/file/d/0B5SCHjXnxzeOZ1ZuRWVqa2pnYm8/view?usp=sharing

1 个答案:

答案 0 :(得分:-1)

Information.java文件中,emergencycontactnumber的Setter方法不正确,

public void setEmergencycontactnumber (String emergencycontactnumber){
    this.name = emergencycontactnumber;
}

虽然应该

public void setEmergencycontactnumber (String emergencycontactnumber){
    this.emergencycontactnumber= emergencycontactnumber;
}

这里发生的是,emergencycontactnumber总是null因为你没有设置它,所以在将数据插入sqlite时会抛出错误,因为在你的create table查询中,你指定了{{1 ,导致错误,您的数据永远不会存在。