DBAdapter:
public void onCreate(SQLiteDatabase db) {
db.execSQL(" CREATE TABLE " + DATABASE_TABLE + " (" + KEY_FIRSTNAME
+ " TEXT NOT NULL, " + KEY_MIDDLENAME + " TEXT NOT NULL, "
+ KEY_LASTNAME + " TEXT NOT NULL, " + KEY_USERNAME + " TEXT NOT NULL, " + KEY_MAIL_ID + " TEXT NOT NULL, "
+ KEY_PASSWORD + " TEXT NOT NULL, " + KEY_CONFIRM
+ " TEXT NOT NULL, " + KEY_DATE_OF_BIRTH
+ " TEXT NOT NULL, " + KEY_COUNTRY + " TEXT NOT NULL "
+ ");");
RegPage.java:
dbadapter = new DBAdapter(RegistrationPage.this);
dbadapter.open();
dbadapter.insertRecord(first_name, middle_name, last_name,
user_name, mail_id, pass_word, confirm_password, d_o_b,coun_try);
logcat的
12-06 11:54:45.861: E/SQLiteDatabase(4898): Error inserting username=arrfan30@gmail.com middlename=MOHAMMED dob=22/11/1990 confirmpassword=black lastname=Rani firstname=Raja password=black mail_id=arrfan30@gmail.com
12-06 11:54:45.861: E/SQLiteDatabase(4898): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.database.sqlite.SQLiteStatement.native_executeInsert(Native Method)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:112)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1732)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1605)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at com.example.signup.DBAdapter.insertRecord(DBAdapter.java:111)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at com.example.signup.RegistrationPage$1.onClick(RegistrationPage.java:83)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.view.View.performClick(View.java:3100)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.view.View$PerformClick.run(View.java:11644)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.os.Handler.handleCallback(Handler.java:587)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.os.Handler.dispatchMessage(Handler.java:92)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.os.Looper.loop(Looper.java:126)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at android.app.ActivityThread.main(ActivityThread.java:3997)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at java.lang.reflect.Method.invoke(Method.java:491)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-06 11:54:45.861: E/SQLiteDatabase(4898): at dalvik.system.NativeStart.main(Native Method)
尝试插入logcat时说“
Error inserting data
”和SQL约束异常错误代码19.有人可以帮我吗?提前致谢。
编辑:
我也扔进了我的logcat。我没有传递任何空值。
答案 0 :(得分:0)
约束失败通常表示你做了类似传递的事情 在创建时声明为非null的列中的null值 你的桌子。
因此,您可以通过调试代码来检查传递的任何值是否为空。
答案 1 :(得分:0)
您的logcat显示缺少国家/地区值。它无法插入或获取名为country的列。
确保国家/地区值不为空。
尝试按以下方式插入记录:
dbadapter.insertRecord(user_name, middle_name, d_o_b,confirm_password,last_name
,first_name,pass_word,mail_id,coun_try);