简体   繁体   English

SQLite 数据库中未存储任何信息

[英]No information stored in SQLite Database

I've been working on a Login-Register application and is currently facing some problem.我一直在研究 Login-Register 应用程序,目前遇到了一些问题。

The problem I encountered was that no data is stored into my SQLite Database even though I was able to enter information and click on the "sign up" button.我遇到的问题是,即使我能够输入信息并单击“注册”按钮,也没有数据存储到我的 SQLite 数据库中。
And whenever I press on the "Login" button, the application will always show "Unfortunately this application stopped".每当我按下“登录”按钮时,应用程序将始终显示“不幸的是,此应用程序已停止”。

Does anyone know why and can help?有谁知道为什么并且可以提供帮助?
I hope to get help soon as I am doing this for my final year project.我希望在我为最后一年的项目做这件事时能尽快得到帮助。

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)

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

In your Information.java file, Setter method of emergencycontactnumber is incorrect,在您的Information.java文件中, emergencycontactnumber Setter 方法不正确,

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

While it should be虽然应该是

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

What happen here is, emergencycontactnumber is always null as you are not setting it, So while inserting data into sqlite throws error, Because in your create table query, you have specified that emergencycontactnumber text not null , Result into error and your data never persist.这里发生的情况是, emergencycontactnumber始终为null因为您没有设置它,因此在将数据插入 sqlite 时会引发错误,因为在您的创建表查询中,您指定了emergencycontactnumber text not null ,结果为错误并且您的数据永远不会持久。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM