简体   繁体   中英

No information stored in SQLite Database

I've been working on a Login-Register application and is currently facing some problem.

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.
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

In your Information.java file, Setter method of emergencycontactnumber is incorrect,

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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